ZhenlongDai/ACPR huggingface dataset:
Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,C = [int(n) for n in input().split()]
if (A+B)>C:
	print("Yes")
else:
	print("No")

Failing test case input:
19 123 142

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
A,B,C = [int(n) for n in input().split()]
if (A+B)>=C:
	print("Yes")
else:
	print("No")

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())
if a + b < c:
    print("yes")
else:
    print("No")

Failing test case input:
120 101 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
a,b,c = map(int,input().split())
if a + b >= c:
    print("Yes")
else:
    print("No")

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = map(int, input().split())

if A + B > C:
  print("Yes")
else:
  print("No")

Failing test case input:
19 123 142

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
A, B, C = map(int, input().split())

if A + B >= C:
  print("Yes")
else:
  print("No")

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())
if a+b*2>=c:
    print("Yes")
else:
    print("No")


Failing test case input:
0 730 1200

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
a,b,c = map(int,input().split())
if a+b>=c:
    print("Yes")
else:
    print("No")

Problem: p03407
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C=map(int,input().split())
print(["Yes","No"][A+2*B<C])

Failing test case input:
31 36 76

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
A,B,C=map(int,input().split())
print(["Yes","No"][A+B<C])

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(int, input().split())

if a*2+b*2 >= c:
    print('Yes')
else:
    print('No')

Failing test case input:
1 123 141

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
a, b, c = map(int, input().split())

if a+b >= c:
    print('Yes')
else:
    print('No')

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,C = [int(i) for i in input().split()]
print("Yes") if A + B * 2 > C else print("No")

Failing test case input:
31 36 76

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
A,B,C = [int(i) for i in input().split()]
print("Yes") if A + B >= C else print("No")

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,C = map(int,input().split())

if A+B*2 >= C:
    print("Yes")
else:
    print("No")

Failing test case input:
31 36 83

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
A,B,C = map(int,input().split())

if A+B >= C:
    print("Yes")
else:
    print("No")
Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())
if a+b<=c:
    print('Yes')
else:
    print('No')

Failing test case input:
0 1224 110

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
a,b,c = map(int,input().split())
if a+b>=c:
    print('Yes')
else:
    print('No')

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c=map(int,input().split())
if a+b > c:
  print("Yes")
else:
  print("No")

Failing test case input:
19 123 142

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
a,b,c=map(int,input().split())
if a+b >= c:
  print("Yes")
else:
  print("No")

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, c = map(int,input().split())
if a + b > c:
  print("Yes")
  
else:
  print("No")

Failing test case input:
19 123 142

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
a, b, c = map(int,input().split())
if a + b >= c:
  print("Yes")
  
else:
  print("No")

Problem: p03407
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a,b,c=map(int,input().split())
print('YNeos'[a+2*b<c::2])

Failing test case input:
1 386 514

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
a,b,c=map(int,input().split())
print('YNeos'[a+b<c::2])

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = map(int, input().split())
if 2*A+2*B >= C:
  print("Yes")
else:
  print("No")

Failing test case input:
726 111 1110

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
A, B, C = map(int, input().split())
if A+B >= C:
  print("Yes")
else:
  print("No")

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, C = map(int, input().split())

if A+B >= C:
    print('Yes')
else:
    print('NO')

Failing test case input:
500 100 1000

Expected output:
No

Actual output:
NO


Fixed submission (verdict: Accepted):
A, B, C = map(int, input().split())

if A+B >= C:
    print('Yes')
else:
    print('No')

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,C=map(int,input().split())
if A+B>C:
  print('No')
elif A+B<C:
  print('Yes')



Failing test case input:
120 011 1

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
A,B,C=map(int,input().split())
if A+B>=C:
  print('Yes')
elif A+B<=C:
  print('No')

Problem: p03407
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c = map(int,input().split())
if a+b>c:
    print("Yes")
else:
    print("No")

Failing test case input:
19 123 142

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
a,b,c = map(int,input().split())
if a+b>=c:
    print("Yes")
else:
    print("No")
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):


import sys
import os
import math

N = int(input())

E = []
E.append([])
d = [None] * (N + 1)

for i in range(N):
    lst = list(map(int, input().split()))
    nodes = lst[2:]
    E.append(nodes)


q = []
q.append(1)

visited = [False] * (N + 1)
d[1] = 0
visited[1] = True

while q:
    index = q.pop(0)

    
    for v in E[index]:
        if not visited[v]:
            q.append(v)
            d[v] = d[index] + 1
            visited[v] = True


for i in range(1, N + 1):
    print(i, d[i])

Failing test case input:
4
1 2 4 4
2 0 4
0 -1
0 0 1

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 0
2 None
3 None
4 1


Fixed submission (verdict: Accepted):


import sys
import os
import math


N = int(input())

E = []
E.append([])
d = [-1] * (N + 1)

for i in range(N):
    lst = list(map(int, input().split()))
    nodes = lst[2:]
    E.append(nodes)


q = []
q.append(1)

visited = [False] * (N + 1)
d[1] = 0
visited[1] = True

while q:
    index = q.pop(0)

    
    for v in E[index]:
        if not visited[v]:
            q.append(v)
            d[v] = d[index] + 1
            visited[v] = True


for i in range(1, N + 1):
    print(i, d[i])

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    print(Q)
    u = Q.pop(0) - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)
    


Failing test case input:
4
1 2 1 4
2 1 4
3 0
4 1 4

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
[1]
[4]
1 0
2 -1
3 -1
4 1


Fixed submission (verdict: Accepted):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop(0) - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            color[v] = "gray"
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop(0) - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)
    



Failing test case input:
4
1 2 2 4
4 1 4
3 0
3 1 0

Expected output:
1 0
2 1
3 -1
4 1


Actual output:
1 0
2 1
3 -1
4 2


Fixed submission (verdict: Accepted):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop(0) - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            color[v] = "gray"
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
queue = [0]


for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

while len(queue) != 0:
    i = queue.pop(0)
    for j in range(n):
        if (graph[i][j] == 1) & (f[j] == 0):
            queue.append(j)
            f[j] = 1
            d[j] = d[i] + 1

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


Failing test case input:
4
1 2 1 1
4 1 4
3 0
4 1 4

Expected output:
1 0
2 -1
3 -1
4 -1


Actual output:
1 1
2 0
3 0
4 0


Fixed submission (verdict: Accepted):
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
queue = [0]


for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

f[0] = 1
while len(queue) != 0:
    i = queue.pop(0)
    for j in range(n):
        if (graph[i][j] == 1) & (f[j] == 0):
            queue.append(j)
            f[j] = 1
            d[j] = d[i] + 1

[print(i+1, d[i] if (i == 0) | (d[i] != 0) else -1) for i in range(n)]
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
N= int(input())
E = [input().split()[2:] for _ in [0]*N]
L,Q = [0] + [-1]*N, [0]
def func(ide):
    for i in E[ide]:
        i = int(i) - 1
        if L[i] < 0 :L[i] = L[ide] +1 ;Q.append(i) 
        else:return

while Q:top = Q.pop();func(top)

for i in range(N):print(i + 1 ,int(L[i]))



Failing test case input:
4
1 2 1 4
2 1 4
3 0
4 1 0

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 0
2 -1
3 -1
4 -1


Fixed submission (verdict: Accepted):
N= int(input())
E = [input().split()[2:] for _ in [0]*N]
Q = [0]
L = [0] + [-1]*N

    


while Q:
    top = Q.pop(0)
    for i in E[top]:
        i = int(i) - 1
        if L[i] < 0 :L[i] = L[top] +1 ; Q+= [i]

for i in range(N):print(i + 1 ,int(L[i]))

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = [[False]*n for i in range(n)]
   
for i in range(n):
    v = list(map(int, input().split()))
    u = v[0]
    k = v[1]
    for j in range(k):
        a[u - 1][v[2 + j] - 1] = True

isDiscovered = [False] * n
distance = [0]*n
 
def dfs(x, d):
    isDiscovered [x] = True
    distance[x] = d
    for i in range(n):
        if a[x][i] and not isDiscovered[i]:
            dfs(i, d+1)

 
for i in range(n):
    if not isDiscovered[i]:
        dfs(i, 1)
 
for i in range(n):
    print(i+1, distance[i])

Failing test case input:
4
1 2 1 4
1 1 4
3 0
4 0 1

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 1
2 1
3 1
4 2


Fixed submission (verdict: Accepted):
n = int(input())
a = [[] for i in range(n)]

for i in range(n):
    v = list(map(int, input().split()))
    u = v[0] - 1
    for j in v[2:]:
        a[u].append(j-1)

d = [-1] * n
isDiscovered = [False] * n

def bfs(x):
    for i in a[x]:
        if not isDiscovered[i]:
            isDiscovered [i] = True
            d[i] = d[x] + 1

d_ = 0
isDiscovered [0] = True
d[0] = 0
bfs(0)

flag = True
while flag:
    flag = False
    for i in range(n):
        if d[i] is d_ :
            flag = True
            bfs(i)
    d_ += 1

for i in range(n):
    print(i+1, d[i])
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [0 for i in range(n)]

while Q != []:
    u = Q.pop() - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

print(" ".join([str(num) for num in d]))
    



Failing test case input:
4
1 2 1 4
2 0 4
3 0
4 1 0

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
0 0 0 1


Fixed submission (verdict: Accepted):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop(0) - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            color[v] = "gray"
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
queue = [0]


for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

while len(queue) != 0:
    i = queue.pop(0)
    for j in range(i, n):
        if (graph[i][j] == 1) & (f[j] == 0):
            queue.append(j)
            f[j] = 1
            d[j] = d[i] + 1

[print(i+1, d[i] if (i == 0) | (d[i] != 0) else -1) for i in range(n)]


Failing test case input:
4
1 2 1 1
2 1 1
3 0
4 1 1

Expected output:
1 0
2 -1
3 -1
4 -1


Actual output:
1 1
2 -1
3 -1
4 -1


Fixed submission (verdict: Accepted):
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
queue = [0]


for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

f[0] = 1
while len(queue) != 0:
    i = queue.pop(0)
    for j in range(n):
        if (graph[i][j] == 1) & (f[j] == 0):
            queue.append(j)
            f[j] = 1
            d[j] = d[i] + 1

[print(i+1, d[i] if (i == 0) | (d[i] != 0) else -1) for i in range(n)]
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
queue = [0]


for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

while len(queue) != 0:
    i = queue.pop(0)
    for j in range(n):
        if (graph[i][j] == 1) & (f[j] == 0):
            queue.append(j)
            f[j] = 1
            d[j] = d[i] + 1

[print(i+1, d[i] if (i == 0) | (d[i] != 0) else -1) for i in range(n)]


Failing test case input:
4
1 2 1 4
1 1 4
2 0
4 0 0

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 1
2 -1
3 -1
4 2


Fixed submission (verdict: Accepted):
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
queue = [0]


for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

f[0] = 1
while len(queue) != 0:
    i = queue.pop(0)
    for j in range(n):
        if (graph[i][j] == 1) & (f[j] == 0):
            queue.append(j)
            f[j] = 1
            d[j] = d[i] + 1

[print(i+1, d[i] if (i == 0) | (d[i] != 0) else -1) for i in range(n)]

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque

n = int(input())
G = []
checked = [False for i in range(n + 1)]
d = [-1 for i in range(n + 1)]
G.append([])
for i in range(n):
    u, k, *v = map(int, input().split())
    G.append(v)

q = deque()
q.append(1)
d[1] = 0

while q:
    current = q.pop()
    for adj in G[current]:
        if not checked[adj]:
            q.append(adj)
            checked[adj] = True
            d[adj] = d[current] + 1

for id in range(1, n + 1):
    print("{0} {1}".format(id, d[id]))

Failing test case input:
4
1 2 1 4
2 -1 4
0 -1
4 1 0

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 1
2 -1
3 -1
4 2


Fixed submission (verdict: Accepted):
n = int(input())

G = []
G.append([])
for i in range(n):
    v = list(map(int, input().split()))
    G.append(v[2:])

q = []
q.append(1)

checked = [False] * (n + 1)
checked[1] = True
d = [-1] * (n + 1)
d[1] = 0

while q:
    current = q.pop(0)
    for v in G[current]:
        if not checked[v]:
            q.append(v)
            d[v] = d[current] + 1
            checked[v] = True

for i in range(1, n + 1):
    print(i, d[i])
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
from queue import Queue

n = int(input())
A = [[0 for i in range(n)] for j in range(n)]
d = [0 for i in range(n)]

for i in range(n):
    u, k, *v = list(map(int, input().split()))
    for j in v:
        A[int(u)-1][int(j)-1] = 1

q = Queue()
q.put(0)
d[0] = 0

while not q.empty():
    u = q.get()
    
    for v in range(n):
        
        if A[u][v] == 1 and d[v] == 0:
            q.put(v)
            d[v] = d[u] + 1


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


Failing test case input:
4
1 2 1 1
2 1 1
0 0
1 1 1

Expected output:
1 0
2 -1
3 -1
4 -1


Actual output:
0 1
1 0
2 0
3 0


Fixed submission (verdict: Accepted):
from queue import Queue

n = int(input())
A = [[0 for i in range(n)] for j in range(n)]
d = [-1 for i in range(n)]

for i in range(n):
    u, k, *v = list(map(int, input().split()))
    for j in v:
        A[int(u)-1][int(j)-1] = 1

q = Queue()
q.put(0)
d[0] = 0

while not q.empty():
    u = q.get()
    
    for v in range(n):
        
        if A[u][v] == 1 and d[v] == -1:
            q.put(v)
            d[v] = d[u] + 1


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

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):


n = int(input())
adj = [[] for _ in range(n)]
d = [-1 for _ in range(n)]
d[0] = 0


for j in range(n):
    ain = list(map(int, input().split()))
    u = ain[0]
    k = ain[1]
    for i in range(k):
        adj[u-1].append(ain[i+2]-1)
    adj[u-1].sort()
    

stack = [0]

while stack:
    
    current = stack[-1]
    flag = 0
    for k in adj[current]:
        if d[k] <= 0:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
    if flag == 0:
        stack.pop()

    
    

for i in range(n):
    print('{} {}'.format(i+1, d[i]))



Failing test case input:
4
1 2 1 4
2 1 1
3 0
4 1 1

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 1
2 -1
3 -1
4 2


Fixed submission (verdict: Accepted):


n = int(input())
adj = [[] for _ in range(n)]
d = [-1 for _ in range(n)]
d[0] = 0


for j in range(n):
    ain = list(map(int, input().split()))
    u = ain[0]
    k = ain[1]
    for i in range(k):
        adj[u-1].append(ain[i+2]-1)
    adj[u-1].sort()
    

stack = [0]

while stack:
    
    current = stack[-1]
    flag = 0
    for k in adj[current]:
        if d[k] < 0:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
        elif d[k] > d[current]+1:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
    if flag == 0:
        stack.pop()

    
    

for i in range(n):
    print('{} {}'.format(i+1, d[i]))
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
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
        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)

Failing test case input:
4
1 2 1 4
3 1 4
3 -1
4 1 2

Expected output:
1 0
2 2
3 -1
4 1


Actual output:
1 0
2 -1
3 -1
4 1


Fixed submission (verdict: Accepted):
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)

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop() - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)
    


Failing test case input:
4
1 2 2 4
2 1 2
3 0
4 1 2

Expected output:
1 0
2 1
3 -1
4 1


Actual output:
1 0
2 2
3 -1
4 1


Fixed submission (verdict: Accepted):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop(0) - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            color[v] = "gray"
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
N= int(input())
E = [input().split()[2:] for _ in range(N)]
frag, T, L,Q = [0]*N, [0]*N,[0] + [-1]*N, [0]
frag[0] = 1
def func(ide):
    for i in E[ide]:
        i = int(i) - 1
        if L[i] < 0 :frag[i] = 1;L[i] = L[ide] +1 ;Q.append(i) 
        else:return

while Q:top = Q.pop();func(top)

for i in range(N):print(i + 1 ,int(L[i]))



Failing test case input:
4
1 2 1 4
3 1 4
3 -1
4 1 4

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 0
2 -1
3 -1
4 -1


Fixed submission (verdict: Accepted):
N= int(input())
E = [input().split()[2:] for _ in [0]*N]
Q = [0]
L = [0] + [-1]*N

    


while Q:
    top = Q.pop(0)
    for i in E[top]:
        i = int(i) - 1
        if L[i] < 0 :L[i] = L[top] +1 ; Q+= [i]

for i in range(N):print(i + 1 ,int(L[i]))

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):


n = int(input())
adj = [[] for _ in range(n)]
d = [-1 for _ in range(n)]
d[0] = 0


for j in range(n):
    ain = list(map(int, input().split()))
    u = ain[0]
    k = ain[1]
    for i in range(k):
        adj[u-1].append(ain[i+2]-1)
    adj[u-1].sort()
    

stack = [0]

while stack:
    print(stack)
    current = stack[-1]
    flag = 0
    for k in adj[current]:
        if d[k] <= 0:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
    if flag == 0:
        stack.pop()

    
    

for i in range(n):
    print('{} {}'.format(i+1, d[i]))



Failing test case input:
4
1 2 1 4
2 1 4
3 0
4 0 4

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
[0]
[0, 0, 3]
[0, 0]
[0]
1 1
2 -1
3 -1
4 2


Fixed submission (verdict: Accepted):


n = int(input())
adj = [[] for _ in range(n)]
d = [-1 for _ in range(n)]
d[0] = 0


for j in range(n):
    ain = list(map(int, input().split()))
    u = ain[0]
    k = ain[1]
    for i in range(k):
        adj[u-1].append(ain[i+2]-1)
    adj[u-1].sort()
    

stack = [0]

while stack:
    
    current = stack[-1]
    flag = 0
    for k in adj[current]:
        if d[k] < 0:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
        elif d[k] > d[current]+1:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
    if flag == 0:
        stack.pop()

    
    

for i in range(n):
    print('{} {}'.format(i+1, d[i]))
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):


n = int(input())
adj = [[] for _ in range(n)]
d = [-1 for _ in range(n)]
d[0] = 0


for j in range(n):
    ain = list(map(int, input().split()))
    u = ain[0]
    k = ain[1]
    for i in range(k):
        adj[u-1].append(ain[i+2]-1)
    adj[u-1].sort()
    

stack = [0]

while stack:
    print(stack)
    current = stack[-1]
    flag = 0
    for k in adj[current]:
        if d[k] < 0:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
        elif d[k] > d[current]+1:
            d[k] = d[current]+1
    if flag == 0:
        stack.pop()

    
    

for i in range(n):
    print('{} {}'.format(i+1, d[i]))



Failing test case input:
4
1 2 2 4
2 0 4
0 -1
4 0 1

Expected output:
1 0
2 1
3 -1
4 1


Actual output:
[0]
[0, 1, 3]
[0, 1]
[0]
1 0
2 1
3 -1
4 1


Fixed submission (verdict: Accepted):


n = int(input())
adj = [[] for _ in range(n)]
d = [-1 for _ in range(n)]
d[0] = 0


for j in range(n):
    ain = list(map(int, input().split()))
    u = ain[0]
    k = ain[1]
    for i in range(k):
        adj[u-1].append(ain[i+2]-1)
    adj[u-1].sort()
    

stack = [0]

while stack:
    
    current = stack[-1]
    flag = 0
    for k in adj[current]:
        if d[k] < 0:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
        elif d[k] > d[current]+1:
            d[k] = d[current]+1
            stack.append(k)
            flag = 1
    if flag == 0:
        stack.pop()

    
    

for i in range(n):
    print('{} {}'.format(i+1, d[i]))

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):
from queue import Queue

n = int(input())
A = [[0 for i in range(n)] for j in range(n)]
d = [-1 for i in range(n)]

for i in range(n):
    u, k, *v = list(map(int, input().split()))
    for j in v:
        A[int(u)-1][int(j)-1] = 1

q = Queue()
q.put(0)
d[0] = 0

while not q.empty():
    u = q.get()
    
    for v in range(n):
        
        if A[u][v] == 1 and d[v] == -1:
            q.put(v)
            d[v] = d[u] + 1


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


Failing test case input:
4
1 2 1 4
3 1 4
3 0
4 1 2

Expected output:
1 0
2 2
3 -1
4 1


Actual output:
0 0
1 2
2 -1
3 1


Fixed submission (verdict: Accepted):
from queue import Queue

n = int(input())
A = [[0 for i in range(n)] for j in range(n)]
d = [-1 for i in range(n)]

for i in range(n):
    u, k, *v = list(map(int, input().split()))
    for j in v:
        A[int(u)-1][int(j)-1] = 1

q = Queue()
q.put(0)
d[0] = 0

while not q.empty():
    u = q.get()
    
    for v in range(n):
        
        if A[u][v] == 1 and d[v] == -1:
            q.put(v)
            d[v] = d[u] + 1


for i in range(n):
    print(i+1, d[i])
Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop() - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

print(" ".join([str(num) for num in d]))
    


Failing test case input:
4
1 2 1 4
0 1 4
0 0
4 0 1

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
0 -1 -1 1


Fixed submission (verdict: Accepted):

n = int(input())
Q = [1]
M = [[False for i in range(n)] for j in range(n)]
dataList = []
for i in range(n):
    data = list(map(int,input().split()))
    dataList.append(data)
    for j in range(data[1]):
        v = data[j+2] - 1
        M[i][v] = True
color = ["white" for i in range(n)]
d = [-1 for i in range(n)]
d[0] = 0
while Q != []:
    u = Q.pop(0) - 1
    color[u] = "gray"
    data = dataList[u]
    for i in range(data[1]):
        v = data[i+2] - 1
        if M[u][v] == True and color[v] == "white":
            color[v] = "gray"
            d[v] = d[u] + 1
            Q.append(v+1)
    color[u] = "black"

for i,j in enumerate(d,1):
    print(i,j)

Problem: p02239
Buggy submission (Python3, verdict: Wrong Answer):

from collections import deque

N = int(input())
adj = [[0]*N for _ in range(N)]
unsearched = set(range(N))
result = {n:-1 for n in range(N)}

for n in range(N):
    inp = list(map(int, input().split()))
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = 1

que = deque([[0, 0]]) 

while len(que):
    q = que.pop()
    result[q[0]] = q[1]
    next_ = [[i, q[1] + 1] for i, a in enumerate(adj[q[0]]) if (a==1) & (i in unsearched)]
    unsearched = unsearched.difference([i[0] for i in next_])
    que.extendleft(next_)

for n in range(N):
    print("{} {}".format(n+1, result[n]))

Failing test case input:
4
1 2 1 4
3 1 0
3 -1
4 1 4

Expected output:
1 0
2 -1
3 -1
4 1


Actual output:
1 1
2 -1
3 -1
4 1


Fixed submission (verdict: Accepted):

from collections import deque

N = int(input())
adj = [[0]*N for _ in range(N)]
unsearched = set(range(1, N))
result = {n:-1 for n in range(N)}

for n in range(N):
    inp = list(map(int, input().split()))
    for i in inp[2:]:
        adj[inp[0]-1][i-1] = 1

que = deque([[0, 0]]) 


while len(que):
    q = que.pop()
    result[q[0]] = q[1]
    next_ = [[i, q[1] + 1] for i, a in enumerate(adj[q[0]]) if (a==1) & (i in unsearched)]
    unsearched = unsearched.difference([i[0] for i in next_])
    que.extendleft(next_)

for n in range(N):
    print("{} {}".format(n+1, result[n]))
Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
output = []
for i in range(n):
    li = input().split(' ')
    if(li[0] == 'insert'):
        output.insert(0, int(li[1]))
    elif(li[0] == 'delete'):
        if(li[1] in output):
            output.remove(int(li[1]))
    elif(li[0] == 'deleteFirst'):
        del output[0]
    elif(li[0] == 'deleteLast'):
        del output[-1]
str_l = [str(o) for o in output]
print(' '.join(str_l))


Failing test case input:
7
tresni 6
insert 2
insert 4
insert 0
delete 3
insert 6
delete 6

Expected output:
0 4 2


Actual output:
6 0 4 2


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
output = deque()
for i in range(n):
    li = input().split(' ')
    if(li[0] == 'insert'):
        output.appendleft(li[1])
    elif(li[0] == 'deleteFirst'):
        output.popleft()
    elif(li[0] == 'deleteLast'):
        output.pop()
    elif(li[0] == 'delete'):
        try:
            output.remove(li[1])
        except:
            pass
print(' '.join(output))

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    cmd = input()
    print('[DEBUG] cmd:',cmd)
    if ' ' in cmd:
        op,v = cmd.split()
    else:
        op = cmd
    if   op == 'insert'     : dl.appendleft(v) 
    elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
    elif op == 'deleteFirst': dl.popleft() 
    elif op == 'deleteLast' : dl.pop() 
print(*dl)

Failing test case input:
7
tresni 4
insert 3
insert 4
insert 1
delete 5
insert 9
delete 8

Expected output:
9 1 4 3


Actual output:
[DEBUG] cmd: tresni 4
[DEBUG] cmd: insert 3
[DEBUG] cmd: insert 4
[DEBUG] cmd: insert 1
[DEBUG] cmd: delete 5
[DEBUG] cmd: insert 9
[DEBUG] cmd: delete 8
9 1 4 3


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
dl = deque()
for _ in range(n):
    cmd = input()
    if ' ' in cmd:
        op,v = cmd.split()
    else:
        op = cmd
    if   op == 'insert'     : dl.appendleft(v) 
    elif op == 'delete'     :
        try: dl.remove(v)
        except ValueError: pass
    elif op == 'deleteFirst': dl.popleft() 
    elif op == 'deleteLast' : dl.pop() 
print(*dl)
Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
def delete(l, num):
    for i, x in enumerate(l):
        if x == num:
            return l[0:i] + l[i+1:]
    return l


n = int(input())
l = []
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        l = [int(com[1])] + l
    elif com[0] == 'delete':
        l = delete(l, int(com[1]))
    elif com[0] == 'deleteFirst':
        l = l[1:]
    elif com[0] == 'deleteLast':
        l = l[:-1]
    print(*l)

Failing test case input:
7
insert 10
tresni 2
insert 3
insert -1
delete 3
insert 0
etedel 9

Expected output:
0 -1 10


Actual output:
10
10
3 10
-1 3 10
-1 10
0 -1 10
0 -1 10


Fixed submission (verdict: Accepted):
import collections
q = collections.deque()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(int(com[1]))
    elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    elif com[0] == 'deleteLast':
        q.pop()
print(*q)

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
def run():
    n = int(input())
    nodes = []
    for _ in range(n):
        order = [o.strip() for o in input().split()]
        if order[0] == 'insert':
            nodes.append(int(order[1]))
        elif order[0] == 'delete':
            if int(order[1]) in nodes:
                nodes.remove(int(order[1]))
        elif order[0] == 'deleteFirst':
            nodes.pop(0)
        elif order[0] == 'deleteLast':
            nodes.pop(0)
    print(' '.join([str(n) for n in nodes]))
    
if __name__ == '__main__':
    run()


Failing test case input:
7
tresni 5
insert 2
insert 4
insert 1
delete 4
insert 9
delete 8

Expected output:
9 1 2


Actual output:
2 1 9


Fixed submission (verdict: Accepted):
from collections import deque

def run():
    n = int(input())
    dq = deque()
    for _ in range(n):
        order = input()
        if order[0] == 'i':
            dq.appendleft(order[7:])
        elif order[6] == ' ':
            key = order.split()[1]
            if not key in dq:
                continue
            for i in range(len(dq)):
                if dq[i] == key:
                    dq.remove(key)
                    break
        elif order[6] == 'F':
            dq.popleft()
        elif order[6] == 'L':
            dq.pop()

    print(' '.join(dq))

if __name__ == '__main__':
    run()
Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque
dq = deque()
for _ in range(int(input())):
    ss = input()
    if ss == "deleteFirst":
        del dq[-1]
    elif ss == "deleteLast":
        del dq[0]
    else:
        c, s = ss.split()
        s = int(s)
        if c == "insert":
            dq.append(s)
        elif c == "delete":
            if s in dq:
                dq.remove(s)
dq.reverse()
print(*dq)



Failing test case input:
7
tresni 2
insert 0
insert 3
insert 0
delete 0
insert 3
eteled 2

Expected output:
3 3 0


Actual output:
3 0 3


Fixed submission (verdict: Accepted):
from collections import deque
dq = deque()
for _ in range(int(input())):
    ss = input()
    if ss == "deleteFirst":
        del dq[0]
    elif ss == "deleteLast":
        del dq[-1]
    else:
        c, s = ss.split()
        s = int(s)
        if c == "insert":
            dq.appendleft(s)
        elif c == "delete":
            if s in dq:
                dq.remove(s)
print(*dq)

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.pop()
    elif c == "deleteLast":
        a.popleft()
    else:
        c, v = c.split()
        if c == "insert":
            a.extendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))


Failing test case input:
7
nresti 5
insert 2
insers 3
insert 2
dflete 3
insert 12
delese 7

Expected output:
12 2 2


Actual output:
2 1 2 2


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.extendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))


Failing test case input:
7
tresni 5
insert 0
insert 3
tresni 1
ddlete 5
insert 10
delete 5

Expected output:
10 3 0


Actual output:
0 1 3 0


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
a = deque()
for i in range(n):
    c = input()
    if c == "deleteFirst":
        a.popleft()
    elif c == "deleteLast":
        a.pop()
    else:
        c, v = c.split()
        if c == "insert":
            a.appendleft(v)
        else:
            try:
                a.remove(v)
            except:
                pass
print(" ".join(a))
Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque
n=int(input())
dq=deque()

for i in range(n):
    cmd=input().split()
    if cmd[0]=="insert":
        dq.appendleft(cmd[1])
    elif cmd[0]=="deleteFirst":
        dq.popleft()
    elif cmd[0]=="deleteLast":
        dq.pop()
    elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            print("Error")
print(*dq)

Failing test case input:
7
tresoi 5
insert 2
insers 5
insert 2
delete 3
insert 2
delete 5

Expected output:
2 2 2


Actual output:
Error
Error
2 2 2


Fixed submission (verdict: Accepted):
from collections import deque
n=int(input())
dq=deque()

for i in range(n):
    cmd=input().split()
    if cmd[0]=="insert":
        dq.appendleft(cmd[1])
    elif cmd[0]=="deleteFirst":
        dq.popleft()
    elif cmd[0]=="deleteLast":
        dq.pop()
    elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            pass
print(*dq)

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

Failing test case input:
7
tresni 5
insert 0
insert 0
tresni 1
ddlete 5
insert 10
delete 5

Expected output:
10 0 0


Actual output:

Fixed submission (verdict: Accepted):
from collections import deque
import sys

dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()

for i in range(num):

    order = line[i].split()

    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])

print(' '.join(dq))

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())

dl_list=[]

for i in range(n):
    cmd=input().split()
    if cmd[0]=="insert":
        dl_list.insert(0,cmd[1])
    elif cmd[0]=="delete":
        try:
            dl_list.remove(cmd[1])
        except:
            print("Error")
    elif cmd[0]=="deleteFirst":
        del dl_list[0]
    elif cmd[0]=="deleteLast":
        del dl_list[-1]

print(*dl_list)

Failing test case input:
7
nresti 5
insert 4
insers 3
insert 2
delete 3
insert 5
edleue 7

Expected output:
5 2 4


Actual output:
Error
5 2 4


Fixed submission (verdict: Accepted):
from collections import deque
n=int(input())
dq=deque()

for i in range(n):
    cmd=input().split()
    if cmd[0]=="insert":
        dq.appendleft(cmd[1])
    elif cmd[0]=="deleteFirst":
        dq.popleft()
    elif cmd[0]=="deleteLast":
        dq.pop()
    elif cmd[0]=="delete":
        try:
            dq.remove(cmd[1])
        except:
            pass
print(*dq)
Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
import collections
q = collections.deque(maxlen=1000000)

n = int(input())
for i in range(n):
    com = input().split()
    if com[0]=='insert':
        q.appendleft(int(com[1]))
    elif com[0]=='delete':
        try:
            q.remove(int(com[0]))
        except ValueError:
            pass
    elif com[0]=='deleteFirst':
        q.popleft()
    elif com[0]=='deleteLast':
        q.pop()
print(*q)

Failing test case input:
7
insert 10
tresni 1
insert 3
insert 0
delete 3
insert 3
etedel 9

Expected output:
3 0 10


Actual output:
3 0 3 10


Fixed submission (verdict: Accepted):
import collections
q = collections.deque()
n = int(input())
for i in range(n):
    com = input().split()
    if com[0] == 'insert':
        q.appendleft(int(com[1]))
    elif com[0] == 'delete':
        try:
            q.remove(int(com[1]))
        except:
            pass
    elif com[0] == 'deleteFirst':
        q.popleft()
    elif com[0] == 'deleteLast':
        q.pop()
print(*q)

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
from collections import deque

n = int(input())
q = deque()

for i in range(n):
    command = input()
    if command[0] == 'i':
        q.appendleft(command[7])
    elif command[6] == ' ':
        try:
            q.remove(command[7])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q))

Failing test case input:
7
insert -2
tioser 0
tresni 0
insert 0
delete 1
tresni 2
delete 4

Expected output:
0 -2


Actual output:
0 -


Fixed submission (verdict: Accepted):
from collections import deque

n = int(input())
q = deque()

for i in range(n):
    command = input()
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q))
Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
commands=[input().split() for i in range(n)]
print(commands)
    
List=[]
def command(list_command):
    if 'insert' in list_command:
        List.insert(0,list_command[1])
    elif 'delete' in list_command:
        try:
            t=List.index(list_command[1])
            del List[t]
        except:
            pass
    elif 'deleteFirst' in list_command:
        del List[0]
    elif 'deleteLast' in list_command:
        del List[-1]

    return True
    
for i in commands:
    command(i)
print(*List)

Failing test case input:
9
insert 11
insert 3
insert 3
tresni 0
delete 3
insert 6
delete 4
deleteFirst
deleteLast

Expected output:
3


Actual output:
[['insert', '11'], ['insert', '3'], ['insert', '3'], ['tresni', '0'], ['delete', '3'], ['insert', '6'], ['delete', '4'], ['deleteFirst'], ['deleteLast']]
3


Fixed submission (verdict: Accepted):
from collections import deque
n=int(input())
commands=[input().split() for i in range(n)]
    
List=deque()
for list_command in commands:
    if 'insert' in list_command:
        List.appendleft(list_command[1])
    elif 'delete' in list_command:
        try:
            List.remove(list_command[1])
        except:
            pass
    elif 'deleteFirst' in list_command:
        List.popleft()
    elif 'deleteLast' in list_command:
        List.pop()
  
print(*List)

Problem: p02265
Buggy submission (Python3, verdict: Wrong Answer):
s=[]
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:s=[e.split()[1]]+s
 else:
  if' '==e[6]:
   m=e.split()[1]
   if m in s:s.remove(m)
  elif len(e)%2:s=s[1:]
  else:s.pop()
 print(*s)


Failing test case input:
7
tresni 4
insert 3
insert 4
insert 1
delete 5
insert 9
delete 8

Expected output:
9 1 4 3


Actual output:

3
4 3
1 4 3
1 4 3
9 1 4 3
9 1 4 3


Fixed submission (verdict: Accepted):
import collections
d=collections.deque()
for _ in range(int(input())):
 e=input()
 if'i'==e[0]:d.appendleft(e.split()[1])
 else:
  if' '==e[6]:
   m=e.split()[1]
   if m in d:d.remove(m)
  elif len(e)%2:d.popleft()
  else:d.pop()
print(*d)