ZhenlongDai/ACPR huggingface dataset:
Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=list(input())
b=list(input()).reverse()
print('NYOE S'[a==b::2])

Failing test case input:
spp
pps

Expected output:
YES


Actual output:
NO 


Fixed submission (verdict: Accepted):
a=list(input())
b=list(input())
b.reverse()
print('NYOE S'[a==b::2])

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = input()

if s[0]==s[2] and s[1]==t[1] and s[2]==s[0]:
  print("YES")
else:
  print("NO")

Failing test case input:
spp
pps

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
s = input()
t = input()
 
if s[0]==t[2] and s[1]==t[1] and s[2]==t[0]:
  print("YES")
else:
  print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s1=input()
s2=input()
if s1[0] == s2[2] and s1[1]==s2[1] and s1[2]==s2[0]:
  print("Yes")
else:
  print("No")

Failing test case input:
yef
elg

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
s1=input()
s2=input()
if s1[0] == s2[2] and s1[1]==s2[1] and s1[2]==s2[0]:
  print("YES")
else:
  print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
b = input()
if a == b[::-1] and b == a[::-1]:
    print('Yes')
else:
    print('No')

Failing test case input:
toq
top

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a = input()
b = input()
if a == b[::-1]:
    print('YES')
else:
    print('NO')

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
  a = input()
  b = input()
  
  if a[0] == b[2]:
    if a[1] == b[1]:
      if a[2] == b[0]:
        print('Yes')
        return
  print('No')
  return

if __name__ == '__main__':
  main()

Failing test case input:
fye
hmh

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
def main():
  a = input()
  b = input()
  
  if a[0] == b[2]:
    if a[1] == b[1]:
      if a[2] == b[0]:
        print('YES')
        return
  print('NO')
  return

if __name__ == '__main__':
  main()

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
print("YNEOS"[input()!=input()[::-1]])


Failing test case input:
{cf
nhg

Expected output:
NO


Actual output:
N


Fixed submission (verdict: Accepted):
print("YNEOS"[input()!=input()[::-1]::2])

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
c1 = input()
c2 = input()

if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0] :
    print("Yes")
else :
    print("No")

Failing test case input:
fez
gmf

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
c1 = input()
c2 = input()

if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0] :
    print("YES")
else :
    print("NO")
Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S1=input()
S2=input()
ans=1
for i in range(3):
  if S1[i]!=S2[2-i]:
    ans*0
print(["NO","YES"][ans])

Failing test case input:
yef
elg

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
S1=input()
S2=input()
ans=1
for i in range(3):
  if S1[i]!=S2[2-i]:
    ans=ans*0
print(["NO","YES"][ans])

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
c1=input()
c2=input()
c2_rev=c2[::-1]
if c1==c2_rev:
    print("YES")
else:
    print("No")

Failing test case input:
efy
glf

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
c1=input()
c2=input()
c2_rev=c2[::-1]
if c1==c2_rev:
    print("YES")
else:
    print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = input()
l = input()
print("Yes" if h[0] == l[2] and l[0] == h[2] and h[1] == l[1] else "No")


Failing test case input:
toq
pot

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
h = input()
l = input()
print("YES" if h[0] == l[2] and l[0] == h[2] and h[1] == l[1] else "NO")

Problem: p03555
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
C1 = str(input().split())

C2 = str(input().split())



if (C1[4] == C2[2]) and (C1[3] == C2[3]):
  print("YES")
else:
  print("NO")

Failing test case input:
rot
top

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
C1 = input()

C2 = input()



if (C1[2] == C2[0]) and (C1[1] == C2[1]) and (C1[0] == C2[2]):
  print("YES")
else:
  print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
print('Yes' if input() == input()[::-1] else 'No')

Failing test case input:
eey
gmf

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
print('YES' if input() == input()[::-1] else 'NO')

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = [input() for i in range(2)]
if a[0] == b[2] and a[2] == b[0]:
    print('YES')
else:
    print('NO')

Failing test case input:
eye
ele

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
a,b = [input() for i in range(2)]
if a[0] == b[2] and a[1]==b[1] and a[2] == b[0]:
    print('YES')
else:
    print('NO')

Problem: p03555
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a = input()
b = input()

a_rev = reversed(a)

if(b == a_rev):
    print('YES')
else:
    print('NO')

Failing test case input:
pot
top

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
a = input()
b = input()

a_rev = ''.join(list(reversed(a)))


if(b == a_rev):
    print('YES')
else:
    print('NO')

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
    print("Yes")
else:
    print("No")

Failing test case input:
fye
gmg

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
    print("YES")
else:
    print("NO")
Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
C1 = list(input())
C2 = list(input())

if (C1[0]==C2[2])&(C1[1]==C2[1])&(C1[2]==C2[0]):
    print("Yes")
else:
    print("No")

Failing test case input:
yef
glf

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
C1 = list(input())
C2 = list(input())

if (C1[0]==C2[2])&(C1[1]==C2[1])&(C1[2]==C2[0]):
    print("YES")
else:
    print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input()
b=input()

if a[0]==b[2] and a[2]==b[0]:
  print("YES")
else:
  print("NO")

Failing test case input:
tbb
bet

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
a=input()
b=input()

if a[0]==b[2] and a[2]==b[0] and a[1]==b[1]:
  print("YES")
else:
  print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a = input()
b = reversed(input())

if a == b:
    print("YES")
else:
    print("NO")

Failing test case input:
pot
top

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):

a = input()
b = input()[::-1]

if a == b:
    print("YES")
else:
    print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
print(['No','Yes'][input()==input()[::-1]])

Failing test case input:
eye
ele

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
print(['NO','YES'][input()==input()[::-1]])

Problem: p03555
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

c = input('')
d = input('')

if c == d[::-1]:
    print('Yes')
else:
    print('No')

Failing test case input:
fyd
hmh

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):

c = input('')
d = input('')

if c == d[::-1]:
    print('YES')
else:
    print('NO')

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
C1 = list(input())
C2 = list(input())
if C1 == C2[::-1]:
    print("Yes")
else:
    print("No")

Failing test case input:
pos
pot

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
C1 = list(input())
C2 = list(input())
if C1 == C2[::-1]:
    print("YES")
else:
    print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input();b=input();print("YNEOS"[a[::-1]!=b])

Failing test case input:
yfe
ele

Expected output:
NO


Actual output:
N


Fixed submission (verdict: Accepted):
a=input();b=input();print("YNEOS"[a[::-1]!=b::2])

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(input())
b = list(input())

if a == b[::-1]:
	print('Yes')
else:
	print('No')

Failing test case input:
tor
top

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
a = list(input())
b = list(input())

if a == b[::-1]:
	print('YES')
else:
	print('NO')

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=list(input())
b=list(input())
print('NYOE S'[a==b.reverse()::2])

Failing test case input:
spp
pps

Expected output:
YES


Actual output:
NO 


Fixed submission (verdict: Accepted):
a=list(input())
b=list(input())
b.reverse()
print('NYOE S'[a==b::2])
Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
b = input()
if a[0]==b[2] and a[1]==b[2] and a[2]==b[0]:
	print("YES")
else: print("NO")

Failing test case input:
spp
pps

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
a = input()
b = input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
	print("YES")
else: print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
C=[input() for i in range(2)]
i=0
while i<2 and C[0][i]==C[1][2-i]:
    i+=1
p="NO"
if i==2:
    p="YES"
print(p)

Failing test case input:
pos
top

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
C=[input() for i in range(2)]
i=0
while i<3 and C[0][i]==C[1][2-i]:
    i+=1
p="NO"
if i==3:
    p="YES"
print(p)

Problem: p03555
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
first = input()
second = input()

if first[0] == second[2] and first[1] == second[1] and first[2] == second[0]:
    print('Yes')
else:
    print('No')

Failing test case input:
{cf
nhg

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
first = input()
second = input()

if first[0] == second[2] and first[1] == second[1] and first[2] == second[0]:
    print('YES')
else:
    print('NO')

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
c=[[i for i in input()] for j in range(2)]
if c[0][0]==c[1][2] and c[0][1]==c[1][1] and c[0][2]==c[1][0]:
  print("Yes")
else:
  print("No")

Failing test case input:
toq
pot

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
c=[[i for i in input()] for j in range(2)]
if c[0][0]==c[1][2] and c[0][1]==c[1][1] and c[0][2]==c[1][0]:
  print("YES")
else:
  print("NO")

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
c1 = input()
c2 = input()
c1 = c1[::-1]
if c1 == c2:
  print("Yes")
else:
  print("No")

Failing test case input:
s`b
aft

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
c1 = input()
c2 = input()
c1 = c1[::-1]
if c1 == c2:
  print("YES")
else:
  print("NO")

Problem: p03555
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s1 = input()
s2 = input()

if s1[0] == s2[2] and s1[1] == s2[1] and s1[2] == s2[0]:
  print('Yes')
else:
  print('No')

Failing test case input:
qot
pot

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
s1 = input()
s2 = input()

if s1[0] == s2[2] and s1[1] == s2[1] and s1[2] == s2[0]:
  print('YES')
else:
  print('NO')

Problem: p03555
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
c1 = list(input())
c2 = list(input())

r1 = c1[::-1]
r2 = c2[::-1]
if c1 == r1 and c2 == r2:
  print("YES")
else:
  print("NO")


Failing test case input:
pot
top

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
c1 = list(input())
c2 = list(input())

r1 = c1[::-1]
r2 = c2[::-1]

if c1 == r2 and c2 == r1:
  print("YES")
else:
  print("NO")
Problem: p02850
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])

while Q:
  temp = Q.popleft()
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now == col[temp]:
      now += 1
    col[n] = now
    now += 1
    Q.append(n)
    
print(m)
for v in col[2:]:
  print(v)

Failing test case input:
8
1 2
2 3
2 4
4 5
4 7
3 6
4 8

Expected output:
4
1
2
3
1
2
1
4


Actual output:
4
1
2
3
1
1
2
4


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
edge = []
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
  edge.append((a,b))
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])

ans = {}
while Q:
  temp = Q.popleft()
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now == col[temp]:
      now += 1
    col[n] = now
    ans[min(temp,n),max(temp,n)] = now
    now += 1
    Q.append(n)
    
print(m)
for a,b in edge:
  print(ans[(a,b)])

Problem: p02850
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
ans=[-1]*(N-1)
rootLine=[0]*N
numLine=[0]*N

for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  numLine[a]+=1
  if numLine[a]==rootLine[a]:
    numLine[a]+=1
  ans[i]=numLine[a]
  rootLine[b]=numLine[a]
print(max(ans))
for i in ans:
  print(i)

Failing test case input:
8
1 2
2 3
2 4
2 5
6 7
3 6
6 8

Expected output:
4
1
2
3
4
2
1
3


Actual output:
4
1
2
3
4
1
1
2


Fixed submission (verdict: Accepted):
N=int(input())
ans=[-1]*(N-1)
rootLine=[0]*N
numLine=[0]*N
l=[]
for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  l.append([a,b,i])
l.sort()

for a,b,i in l:
  numLine[a]+=1
  if numLine[a]==rootLine[a]:
    numLine[a]+=1
  ans[i]=numLine[a]
  rootLine[b]=numLine[a]

print(max(ans))
for i in ans:
  print(i)

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict,deque
from copy import deepcopy

N = int(input())
graph = defaultdict(list)
for _ in range(N-1):
    a, b = map(int,input().split())
    graph[a].append(b)

stack = deque([1])
C = [0] * (N + 1)
while stack:
    v = stack.popleft()
    c = 0
    for w in graph[v]:
        c += 1 + (c + 1 == C[v])
        C[w] = c
        stack.append(w)
        
print(max(C))
for c in C[2::]:
    print(c)


Failing test case input:
8
1 2
2 3
2 4
3 5
6 7
2 6
2 8

Expected output:
5
1
2
3
1
1
4
5


Actual output:
5
1
2
3
1
4
1
5


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

graph = defaultdict(list)
N, *AB = map(int, open(0).read().split())
for a, b in zip(*[iter(AB)] * 2):
    graph[a].append(b)


stack = deque([1])
C = [0] * (N + 1)
while stack:
    v = stack.popleft()
    c = 0
    for w in graph[v]:
        c += 1 + (c + 1 == C[v])
        C[w] = c
        stack.append(w)
        
print(max(C))
print("\n".join(str(C[b]) for b in AB[1::2]))
Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

A=[[] for _ in range(N)]
B=[]
m=0

for _ in range(N-1):
    a,b=map(int,input().split())
    c=0
    while True:
        c+=1
        if c not in A[a-1]:
            B.append(c)
            A[a-1].append(c)
            A[b-1].append(c)
            m=max(m,c)
            break

print(m)
for i in range(N-1):
    print(B[i])





Failing test case input:
8
1 2
2 3
3 4
4 5
6 7
5 6
4 8

Expected output:
3
1
2
1
2
2
1
3


Actual output:
3
1
2
1
2
1
1
3


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

A=[[] for _ in range(N-1)]
B=[0]*N
C=[0]*N
D=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b)
    C[b-1]=i+1

for i in range(N-1): 
    c=0
    for j in A[i]:
        while True:
            c+=1
            if c!=B[i]:
                B[j-1]=c
                break

print(max(B))            

for i in range(1,N):
    D[C[i]]=B[i]

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

Problem: p02850
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
m = len(max(tree,key=len))
col = [0]*(n+1)
Q = deque([1])
print(tree)
while Q:
  temp = Q.popleft()
  pre = col[temp]
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now!=pre:
      col[n]=now
      now += 1
    else:
      col[n]=now+1
      now += 2
    Q.append(n)
    
print(m,*col[2:])

Failing test case input:
8
1 2
2 3
2 4
4 5
4 7
5 6
3 8

Expected output:
3
1
2
3
1
2
2
1


Actual output:
[[], [2], [1, 3, 4], [2, 8], [2, 5, 7], [4, 6], [5], [4], [3]]
3 1 3 4 1 2 2 1


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
edge = []
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
  edge.append((a,b))
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])

ans = {}
while Q:
  temp = Q.popleft()
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now == col[temp]:
      now += 1
    col[n] = now
    ans[min(temp,n),max(temp,n)] = now
    now += 1
    Q.append(n)
    
print(m)
for a,b in edge:
  print(ans[(a,b)])
Problem: p02850
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

n = int(input())
l = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    l[a].append(b)
    l[b].append(a)

m = max(map(len,l)) 

co = [ set(range(1,m+1)) for _ in range(n+1)]

col = [0 for i in range(n+1)]
col[1] = 1

for i in range(1,n+1):
    for la in l[i]:
        if col[la] ==0:
            col[la] = co[i].pop()
            co[la].discard(col[la])
print(m)
for i in range(2,n+1):
    print(col[i])


Failing test case input:
8
1 2
2 3
3 4
3 5
4 7
5 6
2 8

Expected output:
3
1
2
1
3
2
1
3


Actual output:
3
1
2
1
3
1
2
3


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

n = int(input())
l=[[]]
nn = []
for _ in range(n+1):
    l.append([])

for i in range(n-1):
    a,b = map(int,input().split())
    l[a].append(b)
    l[b].append(a)
    nn.append(b)

ml = list(map(len,l)) 
m = max(ml)
co = []
for i in range(n+1):
    co.append( set(range(1,ml[i]+1) ))

col = [0]*(n+1)
col[1] = 1

for i in range(1,n+1):
    for la in l[i]:
        if col[la] ==0:
            col[la] = co[i].pop()
            co[la].discard(col[la])
print(m)
for i in range(n-1):
    print(col[nn[i]])

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
edge = [[] for _ in range(n)]
ans = [0]*(n-1)
for _ in range(n-1):
    u, v = map(int, input().split())
    edge[u-1].append(v-1)
    edge[v-1].append(u-1)

ans[0] = 1
check = [0]*n
check[0] = 1
for i in range(n):
    color = 1
    for j in edge[i]:
        if check[j]:
            continue
        if ans[i-1] == color:
            color += 1
        ans[j-1] = color
        check[j] = 1
        color += 1
        
print(max(ans))
for i in ans:
    print(i)

Failing test case input:
8
1 2
2 3
3 4
2 5
6 7
3 6
7 8

Expected output:
3
1
2
1
3
1
3
2


Actual output:
3
1
2
1
3
3
1
2


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
edge = [[] for _ in range(n)]
ans = [0]*(n-1)
for i in range(n-1):
    u, v = map(int, input().split())
    edge[u-1].append((i, v-1))
    edge[v-1].append((i, u-1))


ans[0] = 1
parents = [-1]*n
que = deque([[0, 0]])
while que:
    a, b = que.popleft()
    color = 1
    for i, j in edge[a]:
        if parents[a] == j:
            continue
        if color == b:
            color += 1
        ans[i] = color
        parents[j] = a
        que.append([j, color])
        color += 1
print(max(ans))
for i in ans: print(i)
Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from collections import deque
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int, input().split())
    G[a-1].append(b-1)

q = deque([0])
color=[0]*(n-1)

while q:
    v=q.popleft()
    c=0
    for nv in G[v]:
        c+=1+(c+1==color[v-1])
        color[nv-1]=c
        q.append(nv)
print(max(color))
print(*color,sep='\n')

Failing test case input:
8
1 2
2 3
2 4
3 5
3 7
5 6
4 8

Expected output:
3
1
2
3
1
3
2
1


Actual output:
3
1
2
3
1
2
3
1


Fixed submission (verdict: Accepted):

from collections import deque

n = int(input())
E = [[] for _ in range(n + 1)]
edge_order = []

for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    edge_order.append(b)


q = deque([1])
color = [0] * (n+1) 
while q:
    V = q.popleft()
    c = 1
    for nv in E[V]:
        if c == color[V]:
            c += 1
        color[nv] = c
        c += 1
        q.append(nv)

print(max(color))
for i in edge_order:
    print(color[i])

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
data = [0]*(N-1)
cho = [0]*(N+1) 
res = [0]*(N-1) 
for i in range(0,N-1):
    di = list(map(int, input().split()))
    di.append(i)
    data[i] = di

data = sorted(data)
print(data)
for i in range(0,N-1):
    if i != 0 and data[i][0] == data[i-1][0]:
        cur += 1
    else:
        cur = 1
    if cur == cho[data[i][0]]: cur += 1
    res[data[i][2]] = cur
    cho[data[i][1]] = cur

print(max(cho))
for item in res:
    print(item)

Failing test case input:
3
1 2
2 3

Expected output:
2
1
2

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


Fixed submission (verdict: Accepted):
N = int(input())
data = [0]*(N-1)
cho = [0]*(N+1) 
res = [0]*(N-1) 
for i in range(0,N-1):
    di = list(map(int, input().split()))
    di.append(i)
    data[i] = di

data = sorted(data)
for i in range(0,N-1):
    if i != 0 and data[i][0] == data[i-1][0]:
        cur += 1
    else:
        cur = 1
    if cur == cho[data[i][0]]: cur += 1
    res[data[i][2]] = cur
    cho[data[i][1]] = cur

print(max(cho))
for item in res:
    print(item)

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

A=[[] for _ in range(N)]
B=[]
m=0

for _ in range(N-1):
    a,b=map(int,input().split())
    c=0
    while True:
        c+=1
        if c not in A[a-1] and c not in A[b-1]:
            B.append(c)
            A[a-1].append(c)
            A[b-1].append(c)
            m=max(m,c)
            break

print(m)
for i in range(N-1):
    print(B[i])





Failing test case input:
8
1 2
2 3
3 4
2 5
6 7
5 6
4 8

Expected output:
3
1
2
1
3
2
1
2


Actual output:
3
1
2
1
3
1
2
2


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

A=[[] for _ in range(N-1)]
B=[0]*N
C=[0]*N
D=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b)
    C[b-1]=i+1

for i in range(N-1): 
    c=0
    for j in A[i]:
        while True:
            c+=1
            if c!=B[i]:
                B[j-1]=c
                break

print(max(B))            

for i in range(1,N):
    D[C[i]]=B[i]

for i in range(1,N):
    print(D[i])
Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

edges = []

for _ in range(N - 1):
    a, b = map(int,input().split())
    edges.append([a, b])

colors = [-1] * (N - 1)

def func(a, p_i, p_color=-1):
    edge_index = []
    color = 1
    for i in range(p_i + 1, N - 1):
        _a, _b = edges[i]
        if _a == a:
            if color == p_color:
                color += 1
            colors[i] = color
            func(_b, i, color)
            color += 1


func(1, -1)

print(max(colors))
for c in colors:
    print(c)

Failing test case input:
8
1 2
2 3
2 4
3 5
6 7
5 6
4 8

Expected output:
3
1
2
3
1
1
2
1


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


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10 ** 6)

N = int(input())

edges = [[] for _ in range(N)]

for i in range(N - 1):
    a, b = map(int,input().split())
    edges[a - 1].append([b - 1, i])

colors = [-1] * (N - 1)

def func(a, p_color=-1):
    color = 1
    for b, i in edges[a]:
        if color == p_color:
            color += 1
        colors[i] = color
        func(b, color)
        color += 1

func(0, -1)

print(max(colors))
for c in colors:
    print(c)

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  S[a-1].append((b-1, i))
  S[b-1].append((a-1, i))

L=[0]*(N-1)


def dfs(node, pre_col,pre_node):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node)
    col+=1


Failing test case input:
8
1 2
2 3
2 4
2 5
6 7
3 6
2 8

Expected output:
5
1
2
3
4
2
1
5


Actual output:

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

import sys
sys.setrecursionlimit(4100000)
S=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  S[a-1].append((b-1, i))
  S[b-1].append((a-1, i))

L=[0]*(N-1)


def dfs(node, pre_col,pre_node):
  col=1
  for next_node, i in S[node]:
    if next_node==pre_node:
      continue
    if col==pre_col:
      col+=1
    L[i]=col
    dfs(next_node, col, node)
    col+=1

dfs(0,-1,-1)

print(max(L))
for l in L:
  print(l)
Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
g=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append((b-1,i))

vc=[0] * n
ec=[-1]*(n-1)
for p,ci in enumerate(g):
    color = 1
    for c, i in ci:
        if vc[p] == c:
            color += 1
        vc[c] = color
        ec[i] = color
        color += 1
        

print(max(ec))
for i in range(n-1):
    print(ec[i])


Failing test case input:
8
1 2
2 3
1 4
4 5
4 7
3 6
6 8

Expected output:
3
1
2
2
1
3
1
2


Actual output:
2
1
1
2
1
2
1
1


Fixed submission (verdict: Accepted):
n=int(input())
g=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append((b-1,i))

vc=[0] * n
ec=[-1]*(n-1)
for p,ci in enumerate(g):
    color = 1
    for c, i in ci:
        if vc[p] == color:
            color += 1
        vc[c] = color
        ec[i] = color
        color += 1
        

print(max(ec))
for i in range(n-1):
    print(ec[i])

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque

N = int(input())

graph = [[] for _ in range(N + 1)]
seq = []

for _ in range(N - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    seq.append(b)



q = deque([1])
color = [0] * (N + 1)

while q:
    checking_parent = q.popleft()
    parent_color = color[checking_parent]
    c = 1
    for child in graph[checking_parent]:
        if c == parent_color:
            c += 1
        
        color[child] = c
        c += 1
        
        q.append(child)

print(max(color))
for i in range(2, N + 1):
    print(color[i])


Failing test case input:
8
1 2
2 3
2 4
4 5
4 7
3 6
4 8

Expected output:
4
1
2
3
1
2
1
4


Actual output:
4
1
2
3
1
1
2
4


Fixed submission (verdict: Accepted):


from collections import deque

N = int(input())

graph = [[] for _ in range(N + 1)]
seq = []

for _ in range(N - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    seq.append(b)



q = deque([1])
color = [0] * (N + 1)

while q:
    checking_parent = q.popleft()
    parent_color = color[checking_parent]
    c = 1
    for child in graph[checking_parent]:
        if c == parent_color:
            c += 1
        
        color[child] = c
        c += 1
        
        q.append(child)

print(max(color))
for i in range(N - 1):
    print(color[seq[i]])
Problem: p02850
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import deque
n=int(input())
arr=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    arr[a-1].append([b-1,i])
    arr[b-1].append([a-1,i])
print(arr)

que=deque([0])
ans=[0]*(n-1)
par=[0]*n
par[0]=-1
while que:
    x=que.popleft()
    p=par[x]
    color=1
    for tup in arr[x]:
        if p==color:
            color+=1
        if ans[tup[1]]==0:
            ans[tup[1]]=color
            par[tup[0]]=color
            color+=1
            que.append(tup[0])
print(max(ans))
print(*ans,sep='\n')

Failing test case input:
8
1 2
2 3
2 4
4 5
6 7
5 6
4 8

Expected output:
3
1
2
3
1
1
2
2


Actual output:
[[[1, 0]], [[0, 0], [2, 1], [3, 2]], [[1, 1]], [[1, 2], [4, 3], [7, 6]], [[3, 3], [5, 5]], [[6, 4], [4, 5]], [[5, 4]], [[3, 6]]]
3
1
2
3
1
1
2
2


Fixed submission (verdict: Accepted):
from collections import deque
n=int(input())
arr=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    arr[a-1].append([b-1,i])
    arr[b-1].append([a-1,i])

que=deque([0])
ans=[0]*(n-1)
par=[0]*n
par[0]=-1
while que:
    x=que.popleft()
    p=par[x]
    color=1
    for tup in arr[x]:
        if p==color:
            color+=1
        if ans[tup[1]]==0:
            ans[tup[1]]=color
            par[tup[0]]=color
            color+=1
            que.append(tup[0])
print(max(ans))
print(*ans,sep='\n')

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from collections import deque
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int, input().split())
    G[a-1].append(b-1)

q = deque([0])
color=[0]*(n+1)

i=0
while q:
    v=q.popleft()
    c=0
    for nv in G[v]:
        if v==0:
            c+=1
        else:
            c+=1+(c+1==color[v-1])
        color[nv-1]=c
        q.append(nv)
print(max(color))
print(*color,sep='\n')

Failing test case input:
8
1 2
1 3
3 4
2 5
3 7
5 6
3 8

Expected output:
4
1
2
1
2
3
1
4


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


Fixed submission (verdict: Accepted):

from collections import deque

n = int(input())
E = [[] for _ in range(n + 1)]
edge_order = []

for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    edge_order.append(b)


q = deque([1])
color = [0] * (n+1) 
while q:
    V = q.popleft()
    c = 1
    for nv in E[V]:
        if c == color[V]:
            c += 1
        color[nv] = c
        c += 1
        q.append(nv)

print(max(color))
for i in edge_order:
    print(color[i])
Problem: p02850
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])

while Q:
  temp = Q.popleft()
  pre = col[temp]
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now!=pre:
      col[n]=now
      now += 1
    else:
      col[n]=now+1
      now += 2
    
    Q.append(n)
    
print(m,*col[2:])

Failing test case input:
8
1 2
2 3
2 4
3 5
5 7
3 6
5 8

Expected output:
3
1
2
3
1
2
3
3


Actual output:
3 1 2 3 1 3 2 3


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
edge = []
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
  edge.append((a,b))
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])

ans = {}
while Q:
  temp = Q.popleft()
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now == col[temp]:
      now += 1
    col[n] = now
    ans[min(temp,n),max(temp,n)] = now
    now += 1
    Q.append(n)
    
print(m)
for a,b in edge:
  print(ans[(a,b)])

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
E = [[] for _ in range(N)]



l = []
for i in range(N-1):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  E[u].append(v)
  E[v].append(u)


color = [-1 for _ in range(N)]



stack = [0]
color[0] = 0
while stack:
  u = stack.pop()
  i = 1
  for v in E[u]:
    if color[v] == -1:
      stack.append(v)
      color[v] = i
      if color[v] == color[u]:
      	color[v] += 1
      	i += 1
      i += 1

print(max(color))
for i in range(1,N):
  print(color[i])


Failing test case input:
8
1 2
2 3
2 4
3 5
5 7
3 6
4 8

Expected output:
3
1
2
3
1
2
3
1


Actual output:
3
1
2
3
1
3
2
1


Fixed submission (verdict: Accepted):
N = int(input())
E = [[] for _ in range(N)]



l = []
for i in range(N-1):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  E[u].append(v)
  E[v].append(u)
  l.append((u,v))


color = [-1 for _ in range(N)]
ans= {}


stack = [0]
color[0] = 0
while stack:
  u = stack.pop()
  i = 1
  for v in E[u]:
    if color[v] == -1:
      stack.append(v)
      color[v] = i
      if color[v] == color[u]:
      	color[v] += 1
      	i += 1
      tmp = [u,v]
      tmp.sort()
      ans[tuple(tmp)] = color[v]
      i += 1

print(max(color))
for a,b in l:
  print(ans[(a,b)])
Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
S = [tuple(map(int, input().split())) for i in range(N-1)]
S.sort()
l=[0]*N
t=1
k=0
A=[]
for i in S:
    if t==i[0]:
        k+=1
        if k==l[i[0]-1]:
            k+=1
        A.append(k)
        l[i[1]-1]=k
    else:
        t=i[0]
        k=1
        if 1==l[i[0]-1]:
            k=2
        A.append(k)
        l[i[1]-1]=k
print(max(A))
print(*A,sep="\n")

Failing test case input:
8
1 2
2 3
2 4
3 5
4 7
5 6
2 8

Expected output:
4
1
2
3
1
1
2
4


Actual output:
4
1
2
3
4
1
1
2


Fixed submission (verdict: Accepted):
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
N=int(input())
S = [list(map(int, input().split()))+[i] for i in range(N-1)]
A=[None]*(N-1)
l=[[] for i in range(N+1)]
t=[0]*N
t[0]=1
for i in S:
    l[i[0]].append((i[1],i[2]))
    l[i[1]].append((i[0],i[2]))
def haba(o,c):
    p=1
    for i in l[o]:
        if t[i[0]-1]==0:
            if c==p:
                p+=1
            A[i[1]]=p
            t[i[0]-1]=1
            haba(i[0],p)
            p+=1
haba(1,0)
print(max(A))
print(*A,sep="\n")

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from collections import deque
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int, input().split())
    G[a-1].append(b-1)

q = deque([0])
color=[0]*n

while q:
    v=q.popleft()
    c=0
    for nv in G[v]:
        c+=1+(c+1==color[v])
        color[nv]=c
        q.append(nv)
del color[0]
print(max(color))
print(*color,sep='\n')

Failing test case input:
8
1 2
2 3
2 4
4 5
3 7
2 6
2 8

Expected output:
5
1
2
3
1
1
4
5


Actual output:
5
1
2
3
1
4
1
5


Fixed submission (verdict: Accepted):

from collections import deque

n = int(input())
E = [[] for _ in range(n + 1)]
edge_order = []

for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    edge_order.append(b)


q = deque([1])
color = [0] * (n+1) 
while q:
    V = q.popleft()
    c = 1
    for nv in E[V]:
        if c == color[V]:
            c += 1
        color[nv] = c
        c += 1
        q.append(nv)

print(max(color))
for i in edge_order:
    print(color[i])
Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
E = [[] for _ in range(N)]



for _ in range(N-1):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  E[u].append(v)
  E[v].append(u)


color = [-1 for _ in range(N)]



stack = [0]
bad = 0
color[0] = 0
while stack:
  u = stack.pop()
  i = 1
  for v in E[u]:
    if color[v] == -1:
      stack.append(v)
      color[v] = i
      if color[v] == color[u]:
      	color[v] += 1
      	i += 1
      i += 1

print(max(color))
for i in range(1,N):
  print(color[i])

Failing test case input:
8
1 2
2 3
3 4
3 5
6 7
4 6
5 8

Expected output:
3
1
2
1
3
1
2
1


Actual output:
3
1
2
1
3
2
1
1


Fixed submission (verdict: Accepted):
N = int(input())
E = [[] for _ in range(N)]



l = []
for i in range(N-1):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  E[u].append(v)
  E[v].append(u)
  l.append((u,v))


color = [-1 for _ in range(N)]
ans= {}


stack = [0]
color[0] = 0
while stack:
  u = stack.pop()
  i = 1
  for v in E[u]:
    if color[v] == -1:
      stack.append(v)
      color[v] = i
      if color[v] == color[u]:
      	color[v] += 1
      	i += 1
      tmp = [u,v]
      tmp.sort()
      ans[tuple(tmp)] = color[v]
      i += 1

print(max(color))
for a,b in l:
  print(ans[(a,b)])

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
n = int(input())
l = [[] for _ in range(n)]
ans = [0]*(n-1)
q = deque()
color = 1 
for i in range(n-1):
    x,y = map(lambda x: int(x)-1, input().split())
    if i == 0:
        s = x 
        q.append(y)
        ans[i] = color
    l[x].append((y,i))
while len(q)>0:
    node = q.popleft()
    c = 1
    for d, ind in l[node]:
        if c == color:
            c += 1
        ans[ind] = c
        c += 1
        q.append(d) 
    color = c
print(max(ans))
for i in ans:
    print(i)

Failing test case input:
8
1 2
2 3
2 4
3 5
4 7
3 6
1 8

Expected output:
3
1
2
3
1
1
3
2


Actual output:
3
1
2
3
1
1
2
0


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
l = [[] for _ in range(n)]
ans = [0]*(n-1)
q = deque()
color = [0]*n 
count = 0
for i in range(n-1):
    x,y = map(lambda x: int(x)-1, input().split())
    if i == 0:
        q.append(x) 
    l[x].append((y,i))
    l[y].append((x,i))
while count<n-1:
    node = q.popleft()
    c = 1
    for d, ind in l[node]:
        if ans[ind] == 0:
            if c == color[node]:
                c += 1
            ans[ind] = c
            q.append(d) 
            color[d] = c 
            c += 1
            count += 1
print(max(ans))
for i in ans:
    print(i)
Problem: p02850
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])

while Q:
  temp = Q.popleft()
  pre = col[temp]
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now!=pre:
      col[n]=now
      now += 1
    else:
      col[n]=now+1
      now += 2
    
    Q.append(n)
    
print(m)
for v in col[2:]:
  print(v)

Failing test case input:
8
1 2
2 3
2 4
4 5
3 7
2 6
3 8

Expected output:
4
1
2
3
1
1
4
3


Actual output:
4
1
2
3
1
4
1
3


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
tree = [[] for i in range(n+1)]
edge = []
for _ in range(n-1):
  a,b = map(int,input().split())
  tree[a].append(b)
  tree[b].append(a)
  edge.append((a,b))
m = len(max(tree,key=len))
col = [0]*(n+1)
col[1]='a'
Q = deque([1])

ans = {}
while Q:
  temp = Q.popleft()
  now = 1
  for n in tree[temp]:
    if col[n]:
      continue
    if now == col[temp]:
      now += 1
    col[n] = now
    ans[min(temp,n),max(temp,n)] = now
    now += 1
    Q.append(n)
    
print(m)
for a,b in edge:
  print(ans[(a,b)])

Problem: p02850
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import deque
n = int(input())
k = 0
data = [[] for _ in range(n)]
ans_index = []

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    ans_index.append(b)

q = deque([0])
color = [0] * n
print(data)
while q:
    cur = q.popleft()
    c = 1
    for x in data[cur]:
        if c == color[cur]:
            c += 1
    
        color[x] = c
        c += 1
        q.append(x)

print(max(color))
for i in ans_index:
    print(color[i])

Failing test case input:
8
1 2
2 3
2 4
3 5
4 7
2 6
7 8

Expected output:
4
1
2
3
1
1
4
2


Actual output:
[[1], [2, 3, 5], [4], [6], [], [], [7], []]
4
1
2
3
1
1
4
2


Fixed submission (verdict: Accepted):
from collections import deque
n = int(input())
k = 0
data = [[] for _ in range(n)]
ans_index = []

for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    data[a].append(b)
    ans_index.append(b)

q = deque([0])
color = [0] * n
while q:
    cur = q.popleft()
    c = 1
    for x in data[cur]:
        if c == color[cur]:
            c += 1
    
        color[x] = c
        c += 1
        q.append(x)

print(max(color))
for i in ans_index:
    print(color[i])
Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from collections import deque
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int, input().split())
    G[a-1].append(b-1)

q = deque([0])
color=[0]*(n-1)

i=0
while q:
    v=q.popleft()
    c=0
    for nv in G[v]:
        c+=1+(c+1==color[v-1])
        color[nv-1]=c
        q.append(nv)
print(max(color))
print(*color,sep='\n')

Failing test case input:
8
1 2
2 3
2 4
3 5
6 7
2 6
2 8

Expected output:
5
1
2
3
1
1
4
5


Actual output:
5
1
2
3
1
4
1
5


Fixed submission (verdict: Accepted):

from collections import deque

n = int(input())
E = [[] for _ in range(n + 1)]
edge_order = []

for i in range(n-1):
    a,b=map(int,input().split())
    E[a].append(b)
    edge_order.append(b)


q = deque([1])
color = [0] * (n+1) 
while q:
    V = q.popleft()
    c = 1
    for nv in E[V]:
        if c == color[V]:
            c += 1
        color[nv] = c
        c += 1
        q.append(nv)

print(max(color))
for i in edge_order:
    print(color[i])

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict,deque

N = int(input())
graph = defaultdict(list)
for _ in range(N-1):
    a, b = map(int,input().split())
    graph[a].append(b)

stack = deque([1])
C = [0] * (N + 1)
while stack:
    v = stack.popleft()
    c = 0
    for w in graph[v]:
        c += 1 + (c + 1 == C[v])
        C[w] = c
        stack.append(w)
        
print(max(C))
print("\n".join(str(C[b]) for b in range(2,N+1)))

Failing test case input:
8
1 2
2 3
2 4
4 5
4 7
2 6
5 8

Expected output:
4
1
2
3
1
2
4
2


Actual output:
4
1
2
3
1
4
2
2


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

graph = defaultdict(list)
N, *AB = map(int, open(0).read().split())
for a, b in zip(*[iter(AB)] * 2):
    graph[a].append(b)


stack = deque([1])
C = [0] * (N + 1)
while stack:
    v = stack.popleft()
    c = 0
    for w in graph[v]:
        c += 1 + (c + 1 == C[v])
        C[w] = c
        stack.append(w)
        
print(max(C))
print("\n".join(str(C[b]) for b in AB[1::2]))
Problem: p02850
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import deque
N = int(input())
edges=[[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edges[a].append((b, i))
    edges[b].append((a, i))

next_set = deque([(0,0)])
colors = [0]*(N-1)
while next_set:
    p, i = next_set.popleft()
    cnt = 1 if colors[i] != 1 else 2
    for q, j in edges[p]:
        if colors[j] != 0:
            continue
        colors[j] = cnt
        cnt += 1
        if cnt == i:
            cnt += 1
        next_set.append((q, j))
print(max(colors))
print(*colors, sep="\n")

Failing test case input:
8
1 2
2 3
2 4
4 5
4 7
2 6
4 8

Expected output:
4
1
2
3
1
2
4
4


Actual output:
4
1
2
3
1
3
4
4


Fixed submission (verdict: Accepted):
from collections import deque
N = int(input())
edges=[[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    edges[a].append((b, i))
    edges[b].append((a, i))

next_set = deque([(0,0)])
colors = [0]*(N-1)
while next_set:
    p, i = next_set.popleft()
    cnt = 1 if colors[i] != 1 else 2
    for q, j in edges[p]:
        if colors[j] != 0:
            continue
        colors[j] = cnt
        cnt += 1
        if cnt == colors[i]:
            cnt += 1
        next_set.append((q, j))
print(max(colors))
print(*colors, sep="\n")

Problem: p02850
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
graph = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a - 1].append((b - 1, i))
    graph[b - 1].append((a - 1, i))
ans = [0] * (n - 1)

from collections import deque

d = deque()
d.append([0, -1])
while d:
    point, color = d.popleft()
    color = 1 if color != 1 else 2
    for a, index in graph[point]:
        if ans[index] == 0:
            ans[index] = color
            d.append([a, color])
            color += 1
print(max(ans))
print(*ans, sep='\n')

Failing test case input:
8
1 2
2 3
2 4
3 5
4 7
3 6
3 8

Expected output:
4
1
2
3
1
1
3
4


Actual output:
3
1
2
3
1
1
2
3


Fixed submission (verdict: Accepted):
n = int(input())
graph = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    graph[a - 1].append((b - 1, i))
    graph[b - 1].append((a - 1, i))
ans = [0] * (n - 1)

from collections import deque

d = deque()
d.append([0, -1])
while d:
    point, prev = d.popleft()
    color = 1 if prev != 1 else 2
    for a, index in graph[point]:
        if ans[index] == 0:
            ans[index] = color
            d.append([a, color])
            color += 1 if prev != color + 1 else 2
print(max(ans))
print(*ans, sep='\n')
Problem: p03657
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
if not (a % 3) * (b % 3) * ((a + b) % 3) :
    print("Posiible")
else: 
    print("Impossible")

Failing test case input:
-2 29

Expected output:
Possible


Actual output:
Posiible


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
if not (a % 3) * (b % 3) * ((a + b) % 3) :
    print("Possible")
else: 
    print("Impossible")

Problem: p03657
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
if a % 3 == 0 or b%3 == 0 or (a+b)%3 ==3:
  print("Possible")
else:
  print("Impossible")

Failing test case input:
-13 4

Expected output:
Possible


Actual output:
Impossible


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
if a % 3 == 0 or b%3 == 0 or (a+b)%3 ==0:
  print("Possible")
else:
  print("Impossible")

Problem: p03657
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a,b = map(int,input().split())

if a%3 == 0 or b%3 == 0 or (a*b)%3 == 0:
    print("Possible")
else:
    print("Impossible")

Failing test case input:
7 -4

Expected output:
Possible


Actual output:
Impossible


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")

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

if not (a+b % 3 or a % 3 or b % 3):
  print('Impossible')
else:
  print('Possible')

Failing test case input:
5 -4

Expected output:
Impossible


Actual output:
Possible


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

if not (a+b) % 3 or not a % 3 or not b % 3:
  print('Possible')
else:
  print('Impossible')

Problem: p03657
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print('Possible') if (a+b)%3==0 else print('Impossible')

Failing test case input:
-4 -18

Expected output:
Possible


Actual output:
Impossible


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
print('Possible') if (a+b)%3==0 or a%3==0 or b%3==0 else print('Impossible')

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

if a%3 == 0:
  print('Possible')
  exit()
if b%3 == 0:
  print('Possible')
  exit()
if (a+b)%3 == 0:
  print('Possible')
  exit()

print('No')

Failing test case input:
5 -4

Expected output:
Impossible


Actual output:
No


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

if a%3 == 0:
  print('Possible')
  exit()
if b%3 == 0:
  print('Possible')
  exit()
if (a+b)%3 == 0:
  print('Possible')
  exit()

print('Impossible')

Problem: p03657
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
if (a+b)%3 == 0:
    print("Possible")
else:
    print("Impossible")

Failing test case input:
-2 81

Expected output:
Possible


Actual output:
Impossible


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
if (a+b)%3 == 0 or a%3 == 0 or b%3 ==0:
    print("Possible")
else:
    print("Impossible")