Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(int(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print(*stack)
        

Fixed submission:
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element in func:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
        else:
            stack.append(float(element))
    print('{:.6f}'.format(stack[0]))

Buggy python submission (verdict: Runtime Error):
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(float(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print('{:.6f}'.format(stack[0]))
        

Fixed submission:
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element in func:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
        else:
            stack.append(float(element))
    print('{:.6f}'.format(stack[0]))

Buggy python submission (verdict: Runtime Error):
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.div }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element.isdigit():
            stack.append(float(element))
        else:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
    print('{:.6f}'.format(stack[0]))
        

Fixed submission:
import sys
f = sys.stdin

from collections import deque
import operator

func = {'+':operator.add,'-':operator.sub,'*':operator.mul,'/':operator.truediv }

for line in f:
    stack = deque()
    for element in line.strip().split():
        if element in func:
            b = stack.pop()
            a = stack.pop()
            stack.append(func[element](a, b))
        else:
            stack.append(float(element))
    print('{:.6f}'.format(stack[0]))
Buggy python submission (verdict: Runtime Error):
import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    teams = [f.readline().split() for i in range(n)]
    
    teams = [(t[0], -t.count('0'), t.count('1'), i) for i, t in enumerate(teams)]
    
    teams.sort(key=operator.itemgetter(1,2,3))
    
    print('\n'.join([t[0] for t in teams]))

Fixed submission:
import sys
import operator
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    teams = [f.readline().split() for i in range(n)]
    
    teams = [(t[0], -t.count('0'), t.count('1'), i) for i, t in enumerate(teams)]
    
    teams.sort(key=operator.itemgetter(1,2,3))
    
    print('\n'.join([t[0] for t in teams]))
Buggy python submission (verdict: Runtime Error):
def fizzbuzz(i):
    if i % 15 == 0:
        return 'FizzBuzz'
    elif i % 5 == 0:
        return 'Buzz'
    elif i % 3 == 0:
        return 'Fizz'
    else:
        return str(i)

import sys
f = sys.stdin

while True:
    m, n = map(int, f.readline().split())
    if m == n == 0:
        break
    member = list(range(1, m + 1))
    s = [f.readline().strip() for _ in range(n)]
    offset = 0
    for i in range(n):
        if s[i] != fizzbuzz(i + 1):
            pos = (i - offset) % m
            member.remove(member[pos])
            offset = i - pos
            if len(member) == 1:
                break
        
    print(*member)

Fixed submission:
def fizzbuzz(i):
    if i % 15 == 0:
        return 'FizzBuzz'
    elif i % 5 == 0:
        return 'Buzz'
    elif i % 3 == 0:
        return 'Fizz'
    else:
        return str(i)

import sys
f = sys.stdin


while True:
    m, n = map(int, f.readline().split())
    if m == n == 0:
        break
    member = list(range(1, m + 1))
    s = [f.readline().strip() for _ in range(n)]

    pos = 0
    for i in range(n):
        if s[i] != fizzbuzz(i + 1):
            del member[pos]
            m = len(member)
            if m == 1:
                break
        else:
            pos += 1
        pos %= m
        
    print(*member)
Buggy python submission (verdict: Runtime Error):
import sys
import string
from collections import Counter

f = sys.stdin

while True:    
    n = int(f.readline())
    if n == 0:
        break
    counters = {c:Counter() for c in string.ascii_lowercase}
    for i in range(n):
        for word in f.readline().strip().split():
            counters[word[0]].update([word])
    c = f.readline().strip()

    candidate = counters[c].most_common()
    candidate.sort(key=operator.itemgetter(0))
    candidate.sort(key=operator.itemgetter(1), reverse=True)
    candidate = [word for word, count in candidate[:5]]
    if len(candidate) == 0:
        print('NA')
    else:
        print(*candidate)

Fixed submission:
import sys
import string
import operator
from collections import Counter

f = sys.stdin

while True:    
    n = int(f.readline())
    if n == 0:
        break
    counters = {c:Counter() for c in string.ascii_lowercase}
    for i in range(n):
        for word in f.readline().strip().split():
            counters[word[0]].update([word])
    c = f.readline().strip()

    candidate = counters[c].most_common()
    candidate.sort(key=operator.itemgetter(0))
    candidate.sort(key=operator.itemgetter(1), reverse=True)
    candidate = [word for word, count in candidate[:5]]
    if len(candidate) == 0:
        print('NA')
    else:
        print(*candidate)
Buggy python submission (verdict: Runtime Error):
def sugoroku(m, d):
    d = [0] + d + [0]
    start, goal = 0, len(d) - 1

    g = [[0 for j in range(len(d))] for i in range(len(d))]
    for i in range(len(d) - 1):
        for mi in range(1, m + 1):
            pos = min(goal, i + mi)
            pos = max(start, pos + d[pos])
            g[i][pos] = 1

    for k in range(len(d)):
        for i in range(len(d)):
            for j in range(len(d)):
                if g[i][k] and g[k][j]:
                    g[i][j] = 1
    
    for i in range(len(d) - 1):
        if g[start][i] and not g[i][goal]:
            return False
    return True

import sys
f = sys.stdin


while True:
    m = int(f.readline())
    if m == 0:
        break
    d = [int(f.readline()) for _ in range(int(f.readline()))]
    print('OK' if sugoroku(m, d) else 'NG')

Fixed submission:
def reachable(graph, init):
    if init not in graph or graph[init] is None:
        return set()
    
    tmp,  graph[init] = graph[init], None

    return tmp.union(* [reachable(graph, i) for i in tmp])

def sugoroku(m, d):
    d = [0] + d + [0]
    start, goal = 0, len(d) - 1

    graph_to = {goal:{goal}}
    graph_from = {start:{start}}
    
    for init in range(len(d) - 1):
        for xi in range(1, 1 + m):
            pos = min(init + xi, goal)
            to = max(start, min(pos + d[pos],goal))
            try:
                graph_to[to].add(init)
            except KeyError:
                graph_to[to] = {init}
            try:
                graph_from[init].add(to)
            except KeyError:
                graph_from[init] = {to}
    
    unreachable_node = reachable(graph_from, start).difference(reachable(graph_to, goal))
    
    return 0 == len(unreachable_node)

import sys
f = sys.stdin

while True:
    m = int(f.readline())
    if m == 0:
        break
    d = [int(f.readline()) for _ in range(int(f.readline()))]
    print('OK' if sugoroku(m, d) else 'NG')
Buggy python submission (verdict: Runtime Error):
import sys
f = sys.stdin


while True:
    n = int(f.readline())
    if n == 0:
        break
    k = [int(ki) for ki in f.readline().split()]
    k = [ki for ki in k if 0 < ki]
    print('NA' if max(k) < 2 else len(k) + 1)

Fixed submission:
import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    k = [int(ki) for ki in f.readline().split()]
    k = [ki for ki in k if 0 < ki]
    print('NA' if len(k) == 0 or max(k) < 2 else len(k) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

students = list(range(n))

pos = 0
for ai in a:
    pos += -ai if is_odd(ai) else ai
    pos %= len(students)
    students = students[:pos] + students[pos + 1:]

for qi in q:
    print(1 if qi in students else 0)

Fixed submission:
import sys
f = sys.stdin

def is_odd(num):
    return num % 2

n,_,_ = map(int,f.readline().split())#_は読み飛ばし
a = list(map(int, f.readline().split()))
q = list(map(int, f.readline().split()))

s = list(range(n))

pos = 0
for ai in a:
    pos += -ai if is_odd(ai) else ai
    pos %= len(s)
    s.pop(pos)

for qi in q:
    print(1 if qi in s else 0)
Buggy python submission (verdict: Runtime Error):
import sys
import bisect

f = sys.stdin

#n = int(f.readline())
a = list(map(int,f))
a[0] = 0
for i in range(1,len(a)):
    a[i] += a[i - 1]

sum_a = a[-1]
third = sum_a // 3

ret = []

for i in range(bisect.bisect_left(a, third)):
    nick1 = bisect.bisect_left(a, a[i] + third,lo=i)
    
    for ni1 in (nick1-1,nick1):
        second = min(third,(sum_a - (a[ni1] - a[i])) // 2)
        nick2 = bisect.bisect_left(a, a[ni1] + second,lo=nick)
        for ni2 in (nick2-1,nick2):
            if len(a) <= ni2:
                continue
            piece1 = a[ni1] - a[i]
            piece2 = a[ni2] - a[ni1]
            piece3 = sum_a - piece1 - piece2
            ret.append(min(piece1,piece2,piece3))
print(max(ret))

Fixed submission:
import sys

f = sys.stdin


def bisect(a,v):
    l,r = 0,len(a)-1
    
    while l != r:
        m = (l + r) // 2
        if a[m] < v:
            l = m + 1
        else:
            r = m
    return l

#n = int(f.readline())
a = list(map(int,f))
a[0] = 0
for i in range(1,len(a)):
    a[i] += a[i - 1]

sum_a = a[-1]
third = sum_a // 3

ret = []

for i in range(bisect(a, third)):
    nick1 = bisect(a, a[i] + third)
    
    for ni1 in (nick1-1,nick1):
        second = (sum_a - (a[ni1] - a[i])) // 2
        second = min(second,third)
        nick2 = bisect(a, a[ni1] + second)
        for ni2 in (nick2-1,nick2):
            if len(a) <= ni2:
                break
            piece1 = a[ni1] - a[i]
            piece2 = a[ni2] - a[ni1]
            piece3 = sum_a - piece1 - piece2
            ret.append(min(piece1,piece2,piece3))
print(max(ret))
Buggy python submission (verdict: Runtime Error):
import sys

f = sys.stdin

n,m,x = map(int,f.readline().split())
h = [None] + [int(f.readline()) for _ in range(n)]
tuple_abt = [tuple(map(int, line.split())) for line in f]

dict_abt = {}
for ai,bi,ti in tuple_abt:
    try:
        if ti <= h[ai]:
            dict_abt[ai][bi] = ti
    except KeyError:
        dict_abt[ai] = {bi:ti}
    try:
        if ti <= h[bi]:
            dict_abt[bi][ai] = ti
    except KeyError:
        dict_abt[bi] = {ai:ti}

class Tree:
    def __init__(self, t, h, jump_t=0, next_h=0):
        if jump_t:
            t += jump_t
            h -= jump_t
            if h < 0:# 登って辻褄を合わせる
                t += -h
                h = 0
            if next_h < h:# 降りて辻褄を合わせる
                t += h - next_h
                h = next_h
        self.t = t
        self.h = h
        self.d = t - h #基本的に高い位置の方が早い為

d = [None] * (n + 1)
d[1] = Tree(0, x)
q = [(d[1].d, 1)] # (d(v), v)
while len(q):
    _, u = q.pop() #コストが最小の木を取得
    if u not in dict_abt:
        continue
    for v, t in dict_abt[u].items():
        dv = Tree(d[u].t, d[u].h, t, h[v])
        if d[v] == None or d[v].d > dv.d:
            d[v] = dv
            q.append((d[v].d, v))
if d[-1]:
    print(d[-1].t + h[-1] - d[-1].h)
else:
    print(-1)

Fixed submission:
import sys
import heapq

f = sys.stdin

n,m,x = map(int,f.readline().split())
h = [None] + [int(f.readline()) for _ in range(n)]
tuple_abt = [tuple(map(int, line.split())) for line in f]

dict_abt = {}
for ai,bi,ti in tuple_abt:
    try:
        if ti <= h[ai]:
            dict_abt[ai][bi] = ti
    except KeyError:
        dict_abt[ai] = {bi:ti}
    try:
        if ti <= h[bi]:
            dict_abt[bi][ai] = ti
    except KeyError:
        dict_abt[bi] = {ai:ti}

class Tree:
    def __init__(self, t, h, jump_t=0, next_h=0):
        if jump_t:
            t += jump_t
            h -= jump_t
            if h < 0:# 登って辻褄を合わせる
                t += -h
                h = 0
            if next_h < h:# 降りて辻褄を合わせる
                t += h - next_h
                h = next_h
        self.t = t
        self.h = h
        self.d = t - h #基本的に高い位置の方が早い為

d = [None] * (n + 1)
d[1] = Tree(0, x)
q = [(d[1].d, 1)] # (d(v), v)
while len(q):
    _, u = heapq.heappop(q) #コストが最小の木を取得
    if u not in dict_abt:
        continue
    for v, t in dict_abt[u].items():
        dv = Tree(d[u].t, d[u].h, t, h[v])
        if d[v] == None or d[v].d > dv.d:
            d[v] = dv
            heapq.heappush(q,(d[v].d, v))
if d[-1]:
    print(d[-1].t + h[-1] - d[-1].h)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
def memoize(f):  
    cache = {}  
    def helper(x):  
        if x not in cache:              
            cache[x] = f(x)  
        return cache[x]  
    return helper 
        
@memoize
def fib(n):
    if n in (0, 1):
        return 1
    else:
        return fib(n - 1) + fib(n - 2)

pritn(fib(int(input())))

Fixed submission:
def memoize(f):  
    cache = {}  
    def helper(x):  
        if x not in cache:              
            cache[x] = f(x)  
        return cache[x]  
    return helper 
         
@memoize
def fib(n):
    if n in (0, 1):
        return 1
    else:
        return fib(n - 1) + fib(n - 2)
 
print(fib(int(input())))
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
rc = [list(map(int, input().split())) for _ in range(n)]
rc_min = rc.index(min(rc))

def calc(rc):
    total = 0
    for i, irc in enumerate(rc):
        if i ==0:
            r, c = irc
        else:
            total += r * c * irc[1]
            c = irc[1]
    return r, c, total
def reverse_calc(rc):
    total = 0
    for i, irc in enumerate(rc[::-1]):
        if i ==0:
            r, c = irc
        else:
            total += r * c * irc[0]
            r = irc[0]
    return r, c, total

total = 0
r1, c1, ret = reverse_calc(rc[:rc_min])
total += ret
r2, c2, ret =calc(rc[rc_min:])
total += ret
total += r1 * c1 * c2
print(total)

Fixed submission:
def memoize(f):  
    cache = {}  
    def helper(x):  
        if x not in cache:              
            cache[x] = f(x)  
        return cache[x]  
    return helper 

def split_rc(rc):
    for i in range(1, len(rc)):
        yield rc[:i], rc[i:]

@memoize
def cost(rc):
    if len(rc) == 1:
        return 0
    return min(calc_cost(first, second) for first, second in split_rc(rc))

def calc_cost(first, second):
    return cost(first) + cost(second) + first[0][0] * first[-1][1] * second[-1][1]

n = int(input())
rc = tuple(tuple(map(int, input().split())) for _ in range(n))
print(cost(rc))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
adj = [list(map(int, input().split()))[2:] for _ in range(n)]

d = [-1] * n

s = 1
q = []
d[s - 1] = 0
q.append(s)
while len(q):
    u = q.pop()
    v = adj[u - 1]
    for vi in v:
        if d[vi - 1] == -1:
            d[vi - 1] = d[u - 1] + 1
    q += v


for i, di in enumerate(d):
    print(i + 1, di)

Fixed submission:
n = int(input())
adj = [list(map(int, input().split()))[2:] for _ in range(n)]

d = [-1] * n

s = 1
q = []
d[s - 1] = 0
q.append(s)
while len(q):
    u = q.pop()
    v = adj[u - 1]
    for vi in v:
        if d[vi - 1] == -1:
            d[vi - 1] = d[u - 1] + 1         
            q.append(vi)
        elif d[vi - 1] > d[u - 1] + 1:
            d[vi - 1] = d[u - 1] + 1            
            q.append(vi)

for i, di in enumerate(d):
    print(i + 1, di)
Buggy python submission (verdict: Time Limit Exceeded):
def memoize(f):  
    cache = {}  
    def helper(x):  
        if x not in cache:              
            cache[x] = f(x)  
        return cache[x]  
    return helper 

def split_apex(a):
    if len(a) == 2:
        yield (a[0],), (a[1],)
    else:
        for i in range(0, len(a)):
            yield (a[i],), a[:i] + a[i + 1:]

@memoize
def wait(a):
    global g
    if len(a) == 1:
        return 0
    return min(calc_wait(apex, apices) for apex, apices in split_apex(a))

def calc_wait(apex, apices):
    global g
    w = [g[apex[0]][i] for i in apices if g[apex[0]][i] != -1]
    return  wait(apex) + wait(apices) + (min(w) if len(w) else 200000)

n = int(input())
g = [None] + [[None] + list(map(int, input().split())) for _ in range(n)]

a = tuple(i + 1 for i in range(n))
print(wait(a))

Fixed submission:
class Forest:
    def __init__(self, g, id):
        self.forest = set([id])
        self.graph = g
        self.next_wait = self.graph[id]
        self.wait = 0
    def add_tree(self, id):
        self.wait += self.next_wait[id]
        self.forest.update([id])
         
        self.marge_next_wait(id)
    def next_tree(self):
        min_id = min_wait = None
        for id, wait in self.next_wait.items():
            if id not in self.forest:
                if min_wait == None or min_wait > wait:
                    min_wait = wait
                    min_id = id
        return min_id
    def marge_next_wait(self, merge_id):
        for id, wait in self.graph[merge_id].items():
            if id not in self.next_wait or self.next_wait[id] > wait:
                self.next_wait[id] = wait
n = int(input())
g = [{e:i for e, i in enumerate(map(int, input().split())) if i != -1} for _ in range(n)]
forest = Forest(g,0)
for i in range(n - 1):
    id = forest.next_tree()
    forest.add_tree(id)
print(forest.wait)
Buggy python submission (verdict: Runtime Error):
import io, sys, itertools
f = sys.stdin
 
 
def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)
 
 
n = int(f.readline())
adj =[[(v, c) for v, c in take2(map(int, f.readline().split()[2:]))] for _ in range(n)]
d = [100000 * 100 + 1] * n
 
d[0] = 0
def search(parent, children):
    global d
    for v, c in children:
        if d[v] > d[parent] + c:
            d[v] = d[parent] + c
            search(v, adj[v])
     
search(0, adj[0])
     
for i in range(n):
    print(i, d[i])

Fixed submission:
import sys, itertools
f = sys.stdin

def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)

n = int(f.readline())
adj =[[(v, c) for v, c in take2(map(int, f.readline().split()[2:]))] for _ in range(n)]
d = [100000 * 100 + 1] * n

d[0] = 0
queue ={0}
while len(queue):
    parent = queue.pop()
    for v, c in adj[parent]:
        if d[v] > d[parent] + c:
            d[v] = d[parent] + c
            queue.update([v])

for i in range(n):
    print(i, d[i])

Buggy python submission (verdict: Time Limit Exceeded):
import sys, itertools
f = sys.stdin

def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)

n = int(f.readline())
adj =[[(v, c) for v, c in take2(map(int, f.readline().split()[2:]))] for _ in range(n)]
d = [100000 * 100 + 1] * n

d[0] = 0
queue =[0]
while len(queue):
    parent = queue.pop()
    for v, c in adj[parent]:
        if d[v] > d[parent] + c:
            d[v] = d[parent] + c
            queue.append(v)

for i in range(n):
    print(i, d[i])

Fixed submission:
import sys, itertools
f = sys.stdin

def take2(iterable):
    i = iter(iterable)
    while True:
        yield next(i), next(i)

n = int(f.readline())
adj =[[(v, c) for v, c in take2(map(int, f.readline().split()[2:]))] for _ in range(n)]
d = [100000 * 100 + 1] * n

d[0] = 0
queue ={0}
while len(queue):
    parent = queue.pop()
    for v, c in adj[parent]:
        if d[v] > d[parent] + c:
            d[v] = d[parent] + c
            queue.update([v])

for i in range(n):
    print(i, d[i])
Buggy python submission (verdict: Runtime Error):
primes = [2]

def is_prime(num):
    root = num ** 0.5
    for prime in primes:
        if root < prime:
            break
        if num % prime == 0:
            return False
    return True

def create_primes(primes, max):
    for i in range(primes[-1] + 1,max):
        if is_prime(i):
            primes += [i]

create_primes(primes, 10000)

n = int(input())   
for _ in range(n):
    if is_prime(int(input())):
        count += 1
print(count)

Fixed submission:
primes = [2]

def is_prime(num):
    root = num ** 0.5
    for prime in primes:
        if root < prime:
            break
        if num % prime == 0:
            return 0
    return 1

def create_primes(primes, max):
    for i in range(primes[-1] + 1,max):
        if is_prime(i):
            primes += [i]

count = 0
n = int(input())
s = [int(input()) for _ in range(n)]

create_primes(primes, int(max(s) ** 0.5))

print(sum(is_prime(i) for i in s))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
R = [int(input()) for _ in range(N)]

ret = R[1] - R[0]
for i in range(N - 1):
    tmp = max(R[i + 1:]) - R[i]
    if tmp > ret:
        ret = tmp
print(ret)

Fixed submission:
N = int(input())
R = [int(input()) for _ in range(N)]

p_buy = R[0]
p_sale = R[1]
buy = R[1]
sale = None
for i in range(2, N):
    if p_sale < R[i]:
        p_sale = R[i]
    if buy > R[i]:
        if sale is None:
            sale = R[i]
        if p_sale - p_buy < sale - buy:
            p_sale, p_buy = sale, buy 
        sale, buy = None, R[i]
    else:
        if sale is None or sale < R[i]:
            sale = R[i]

p_gain = p_sale - p_buy
print(p_gain if sale is None else max(p_gain, sale - buy))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
processes = []
for i in range(n):
    name, time =  input().split()
    processes += [[name, int(time)]]

progress = 0

while len(processes):
    target = processes[0]
    if target[1] > q:
        target[1] -= q
        progress += q
        processes = processes[1:] + [target]
    else:
        progress += target[1]
        processes = processes[1:]
        print(target[0], progress)     

Fixed submission:
import sys
n, q = map(int, sys.stdin.readline().split())
processes = []
for i in range(n):
    name, time =sys.stdin.readline().split()
    processes += [[name, int(time)]]

progress = 0

while len(processes):
    new_processes = []
    for target in processes:
        if target[1] > q:
            target[1] -= q
            progress += q
            new_processes += [target]
        else:
            progress += target[1]
            print(target[0], progress)
    processes = new_processes
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys

dlist = deque()

func = {'insert':dlist.appendleft, 'delete':dlist.remove, 'deleteFirst':dlist.popleft, 'deleteLast':dlist.pop}

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

for line in sys.stdin:
    command = line.split()
    if len(command) == 2:
        command[1] = int(command[1])
    func[command[0]](*command[1:])

print(*dlist)

Fixed submission:
from collections import deque
import sys

dlist = deque()

func = {'insert':dlist.appendleft, 'delete':dlist.remove, 'deleteFirst':dlist.popleft, 'deleteLast':dlist.pop}

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

for line in sys.stdin:
    command = line.split()
    if len(command) == 2:
        command[1] = int(command[1])
    try:
        func[command[0]](*command[1:])
    except ValueError:
        pass

print(*dlist)