Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())

A = [0]*10001
for i in range(10001):
    A[i] = math.floor(math.sqrt(i))

n,nn,nnn,nnnn = 0,0,0,0
for n in range(1,N+1):
    ans = 0
    for x in range(1,A[n]+1):
        nn = n - x * x
        for y in range(1,A[nn]+1):
            nnn = nn - y * y - y * x
            if nnn <= 0:
                break
            for z in range(1,A[nnn]+1):
                nnnn = nnn - z * z - z * x - z * y
                if nnnn < 0:
                    break
                elif nnnn == 0:
                    ans += 1
                    break
    print(ans)

Fixed submission:
import math
from collections import defaultdict

N = int(input())
D = defaultdict(int)

NN = math.floor(math.sqrt(N))
for x in range(1,NN+1):
    for y in range(1,NN+1):
        for z in range(1,NN+1):
            a = x * x + y * y + z * z + x * y + y * z + z * x
            if a <= N:
                D[a] += 1

for i in range(1,N+1):
    print(D[i])
Buggy python submission (verdict: Runtime Error):
import math

A = [0]*200001
for i in range(18):
    for j in range(2**i,2**(i+1)):
        if j <= 200000:
            A[j] = i + 1

def bii(x):
    a = A[x]
    o = [0]*a
    for i in range(a):
        o[i] = x % 2
        x //= 2
    return o

def f(x):
    bi = bii(x)
    popcount = sum(bi)
    a = x % popcount
    if a == 0:
        return 1
    else:
        return f(a)+1

N = int(input())
X = list(map(int,list(input())))
X.reverse()

popc = sum(X)
D = dict()
E = dict()
for j in [popc-1,popc+1]:
    E[j] = 0
    D[j] = [0]*N
    b = 1
    for i in range(N):
        D[j][i] = b
        E[j] += X[i] * b
        E[j] %= j
        b *= 2
        b %= j

aaaa = []
for i in range(N):
    an = X[-(i+1)]
    bb = 1 - 2 * an
    #もしi桁目が1ならば、ビット反転によってpopcとXは減る
    #もしi桁目が0ならば、ビット反転によってpopcとXは増える
    j = popc + bb
    su = (E[j] + bb * D[j][-(i+1)] + j) % j
    if su == 0:
        print(1)
    else:
        print(f(su)+1)

Fixed submission:
import math

A = [0]*200001
for i in range(18):
    for j in range(2**i,2**(i+1)):
        if j <= 200000:
            A[j] = i + 1

def bii(x):
    a = A[x]
    o = [0]*a
    for i in range(a):
        o[i] = x % 2
        x //= 2
    return o

def f(x):
    bi = bii(x)
    popcount = sum(bi)
    a = x % popcount
    if a == 0:
        return 1
    else:
        return f(a)+1

N = int(input())
X = list(map(int,list(input())))
X.reverse()

popc = sum(X)
D = dict()
E = dict()
for j in [popc-1,popc+1]:
    E[j] = 0
    D[j] = [0]*N
    b = 1
    if j == 0:
        continue
    for i in range(N):
        D[j][i] = b
        E[j] += X[i] * b
        E[j] %= j
        b *= 2
        b %= j

aaaa = []
for i in range(N):
    an = X[-(i+1)]
    bb = 1 - 2 * an
    #もしi桁目が1ならば、ビット反転によってpopcとXは減る
    #もしi桁目が0ならば、ビット反転によってpopcとXは増える
    if popc == 1 and an == 1:
        print(0)
        continue
    j = popc + bb
    su = (E[j] + bb * D[j][-(i+1)] + j) % j
    if su == 0:
        print(1)
        continue
    else:
        print(f(su)+1)
        continue
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = [0]*(max(A))

for i in A:
    B[i-1] += 1

ans = 0
for i in sorted(A):
    if B[i-1] == 0:
        continue
    if B[i-1] == 1:
        ans += 1
    for j in range(i,max(A)+1,i):
        B[j-1] = 0

print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
B = [0]*(maxA)

for i in A:
    B[i-1] += 1

ans = 0
for i in sorted(A):
    if B[i-1] == 0:
        continue
    if B[i-1] == 1:
        ans += 1
    for j in range(i,maxA+1,i):
        B[j-1] = 0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = [0]*(max(A))

for i in A:
    B[i-1] += 1

ans = 0
C = set()
for i in sorted(set(A)):
    if i in C:
        continue
    if B[i-1] == 1:
        ans += 1
    for j in range(2 * i,max(A)+1,i):
        if B[j-1]:
            C.add(j)
            B[j-1] = 0

print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
B = [0]*(maxA)

for i in A:
    B[i-1] += 1

ans = 0
for i in sorted(A):
    if B[i-1] == 0:
        continue
    if B[i-1] == 1:
        ans += 1
    for j in range(i,maxA+1,i):
        B[j-1] = 0

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
B = [0]*(max(A))

for i in A:
    B[i-1] += 1

ans = 0
for i in range(1,max(A)+1):
    if B[i-1] == 0:
        continue
    if B[i-1] == 1:
        ans += 1
    for j in range(2 * i,max(A)+1,i):
        B[j-1] = 0

print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
maxA = max(A)
B = [0]*(maxA)

for i in A:
    B[i-1] += 1

ans = 0
for i in sorted(A):
    if B[i-1] == 0:
        continue
    if B[i-1] == 1:
        ans += 1
    for j in range(i,maxA+1,i):
        B[j-1] = 0

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))

A.append(0)

for j in range(K):
    B = [0] * (N+1)
    for i in range(N):
        B[max(i - A[i],0)] += 1
        B[min(i + A[i] + 1,N)] -= 1
    A = [0] * (N+1)
    a = 0
    for i in range(N):
        a += B[i]
        A[i] = a

print(*A[:-1])

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

A.append(0)

for j in range(min(50,K)):
    B = [0] * (N+1)
    for i in range(N):
        B[max(i - A[i],0)] += 1
        B[min(i + A[i] + 1,N)] -= 1
    A = [0] * (N+1)
    a = 0
    for i in range(N):
        a += B[i]
        A[i] = a

print(*A[:-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(lambda x: int(x)-1,input().split()))

o = [0] * 63

def bi(x):
    i = 0
    while x != 0:
        o[i] = x%2
        x //= 2
        i += 1

bi(K)

n = 0
for i in range(63):
    if o[i]:
        n = A[n]
    A = [A[A[x]] for x in range(N)]
        
print(n+1)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] -= 1

P = [-1]*N
P[0] = 0

cnt = 0
NOW = 0
while True:
    NOW = A[NOW]
    cnt += 1
    if P[NOW] == -1:
        P[NOW] = cnt
        if cnt == K:
            print(NOW+1)
            exit()
    else:
        L = cnt - P[NOW]
        for i in range(P[NOW],P[NOW]+L):
            if K % L != i % L:
                continue
            for k,v in enumerate(P):
                if v == i:
                    print(k+1)
                    exit()

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

N,K = map(int,input().split())
a = np.matrix(np.zeros((N,N)))
for k,v in enumerate(map(int,input().split())):
    v -= 1
    a[k,v] = 1

b = np.matrix(np.zeros(N))
b[0,0] = 1

o = [0] * 63

def bi(x):
    i = 0
    while x != 0:
        o[i] = x%2
        x //= 2
        i += 1

bi(K)

for i in range(63):
    if i:
        a = a * a
    if o[i]:
        b = b * a

for i in range(N):
    if b[0,i]:
        print(i+1)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] -= 1

P = [-1]*N
P[0] = 0

cnt = 0
NOW = 0
while True:
    NOW = A[NOW]
    cnt += 1
    if P[NOW] == -1:
        P[NOW] = cnt
        if cnt == K:
            print(NOW+1)
            exit()
    else:
        L = cnt - P[NOW]
        for i in range(P[NOW],P[NOW]+L):
            if K % L != i % L:
                continue
            for k,v in enumerate(P):
                if v == i:
                    print(k+1)
                    exit()
Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353

def bi(x):
    o = []
    while x != 0:
        o.append(x%2)
        x //= 2
    return o

def modpow(m,n):
    o = 0
    leo = 0
    if n == 1000000005:
        o = [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1]
        leo = 30
    else:
        o = bi(n)
        leo = len(o)
    p = [m] + [0] * (leo - 1)
    for i in range(1,leo):
        a = p[i-1]
        a *= a
        a %= mod
        p[i] = a
    b = 1
    for i in range(leo):
        if o[i]:
            b *= p[i]
            b %= mod
    return b

N,M,K = map(int,input().split())

C = [1]*(K+1)
for i in range(1,K+1):
    C[i] = C[i-1] * (N-i) // i

M1 = [1]*N
for i in range(1,N):
    M1[i] = M1[i-1] * (M-1)
    M1[i] %= mod

ans = 0
for k in range(0,K+1):
    ans += C[k] * M * M1[N-k-1]
    ans %= mod

print(ans)


Fixed submission:
def a():
    mod = 998244353

    def bi(x):
        o = []
        while x != 0:
            o.append(x%2)
            x //= 2
        return o

    o = bi(mod - 2)
    leo = len(o)
    p = [0] * leo

    def modinv(m):
        p[0] = m
        for i in range(1,leo):
            a = p[i-1]
            a *= a
            a %= mod
            p[i] = a
        b = 1
        for i in range(leo):
            if o[i]:
                b *= p[i]
                b %= mod
        return b

    N,M,K = map(int,input().split())

    C = [1]*(K+1)
    for i in range(1,K+1):
        C[i] = (C[i-1] * (N-i) * modinv(i))%mod

    M1 = [1]*N
    for i in range(1,N):
        M1[i] = M1[i-1] * (M-1)
        M1[i] %= mod

    ans = 0
    for k in range(0,K+1):
        ans += C[k] * M * M1[N-k-1]
        ans %= mod

    print(ans)

a()
Buggy python submission (verdict: Runtime Error):
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if and vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki,-kj)
            exit()



Fixed submission:
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki,-kj)
            exit()

Buggy python submission (verdict: Runtime Error):
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if and vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki+1,-(kj+1))
            exit()



Fixed submission:
X = int(input())

FIVES = [x ** 5 for x in range(200)]

for ki,vi in enumerate(FIVES):
    for kj,vj in enumerate(FIVES):
        if vi - vj == X:
            print(ki,kj)
            exit()
        if vj - vi == X:
            print(kj,ki)
            exit()
        if vi + vj == X:
            print(ki,-kj)
            exit()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from collections import Counter

N,M,K = map(int,input().split())

fn = defaultdict(lambda: 1)
CD = [0]*K

par = list(range(N))

def root(x):
    if par[x] == x:
        return x
    y = root(par[x])
    par[x] = y
    return y

def unite(x,y):
    rx = root(x)
    ry = root(y)
    par[rx] = ry

def same(x,y):
    return root(x) == root(y)

for _ in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    fn[A] += 1
    fn[B] += 1
    unite(A,B)
    
for _ in range(K):
    C,D = map(int,input().split())
    C -= 1
    D -= 1
    CD[_] = (C,D)

par = [root(x) for x in range(N)]
c = Counter(par)

RESULT = [(c[par[x]] - fn[x]) for x in range(N)]

for C,D in CD:
    if par[C] == par[D]:
        RESULT[C] -= 1
        RESULT[D] -= 1

print(*RESULT,sep=" ")

Fixed submission:
from collections import defaultdict
from collections import Counter

N,M,K = map(int,input().split())

fn = defaultdict(lambda: 1)
CD = [0]*K

par = list(range(N))

def root(x):
    S = set()
    S.add(x)
    y = x
    while True:
        if par[y] == y:
            for s in S:
                par[s] = y
            return y
        S.add(y)
        y = par[y]

def unite(x,y):
    rx = root(x)
    ry = root(y)
    par[rx] = ry

for _ in range(M):
    A,B = map(int,input().split())
    A -= 1
    B -= 1
    fn[A] += 1
    fn[B] += 1
    unite(A,B)
    
for _ in range(K):
    C,D = map(int,input().split())
    C -= 1
    D -= 1
    CD[_] = (C,D)

par = [root(x) for x in range(N)]
c = Counter(par)

RESULT = [(c[par[x]] - fn[x]) for x in range(N)]

for C,D in CD:
    if par[C] == par[D]:
        RESULT[C] -= 1
        RESULT[D] -= 1

print(*RESULT,sep=" ")
Buggy python submission (verdict: Time Limit Exceeded):
def a():
    N,M = map(int,input().split())
    B = list(map(lambda x: int(x)//2,input().split()))

    def gcd(n,m):
        while n:
            m,n = [n,m%n]
        return m

    su = 1
    for b in B:
        su *= b // gcd(su,b)

    for _ in filter(lambda x:(su//x)%2==0,B):
        return 0

    return M//su - M//(su*2)

print(a())

Fixed submission:
def a():
    N,M = map(int,input().split())
    B = list(map(lambda x: int(x)//2,input().split()))

    def gcd(n,m):
        while n:
            m,n = [n,m%n]
        return m

    su = 1
    for b in B:
        su *= b // gcd(su,b)
        if su > M:
            return 0

    for _ in filter(lambda x:(su//x)%2==0,B):
        return 0

    return M//su - M//(su*2)

print(a())

Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

N,M = map(int,input().split())
B = list(map(lambda x: int(x)//2,input().split()))

@lru_cache(maxsize=1000)
def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

su = 1
for b in B:
    su = su * b // gcd(su,b)

for b in B:
    if (su // b) % 2 == 0:
        print(0)
        exit()

print(M//su - M//(su*2))

Fixed submission:
def a():
    N,M = map(int,input().split())
    B = list(map(lambda x: int(x)//2,input().split()))

    def gcd(n,m):
        while n:
            m,n = [n,m%n]
        return m

    su = 1
    for b in B:
        su *= b // gcd(su,b)
        if su > M:
            return 0

    for _ in filter(lambda x:(su//x)%2==0,B):
        return 0

    return M//su - M//(su*2)

print(a())

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(lambda x: x//2,A))

def gcd(n,m):
    while n:
        m,n = [n,m%n]
    return m

su = 1
for b in B:
    su = su * b // gcd(su,b)

for b in B:
    if (su // b) % 2 == 0:
        print(0)
        exit()

print(M//su - M//(su*2))

Fixed submission:
def a():
    N,M = map(int,input().split())
    B = list(map(lambda x: int(x)//2,input().split()))

    def gcd(n,m):
        while n:
            m,n = [n,m%n]
        return m

    su = 1
    for b in B:
        su *= b // gcd(su,b)
        if su > M:
            return 0

    for _ in filter(lambda x:(su//x)%2==0,B):
        return 0

    return M//su - M//(su*2)

print(a())
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())

N -= 1
A -= 1
B -= 1

def is_valid(p):
    x,y = p
    return 0 <= x < N and 0 <= y < N

def meet(p):
    x,y = p
    return abs(x-y)//2

def dist(p1,p2):
    x1,y1 = p1
    x2,y2 = p2
    return (abs(x1-x2)+abs(y1-y2))//2

oo = []
if (A + B)%2:
    o = []
    for i in [0,N]:
        for j in [1,-1]:
            o.append((i,B + j * abs(A-i)))
            o.append((A + j * abs(B-i),i))
    for x,y in filter(is_valid,o):
        for i in [1,-1]:
            for j in [1,-1]:
                xx = max(0,min(x+i,N))
                yy = max(0,min(y+i,N))
                oo.append(meet((xx,yy))+dist((A,B),(x,y))+1)
    print(min(oo))
else:
    print(meet((A,B)))

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

if (A + B)%2 == 0:
    print(abs(A - B)//2)
else:
    print(min(A-1,N-B)+1+abs(A-B+1)//2)

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

N -= 1
A -= 1
B -= 1

def is_valid(p):
    x,y = p
    return 0 <= x < N and 0 <= y < N

def meet(p):
    x,y = p
    return abs(x-y)//2

def dist(p1,p2):
    x1,y1 = p1
    x2,y2 = p2
    return (abs(x1-x2)+abs(y1-y2))//2

oo = []
if (A + B)//2:
    o = []
    for i in [0,N]:
        for j in [1,-1]:
            o.append((i,B + j * abs(A-i)))
            o.append((A + j * abs(B-i),i))
    for x,y in filter(is_valid,o):
        for i in [1,-1]:
            for j in [1,-1]:
                xx = max(0,min(x+i,N))
                yy = max(0,min(y+i,N))
                oo.append(meet((xx,yy))+dist((A,B),(x,y))+1)
    print(min(oo))
else:
    print(meet((A,B)))

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

if (A + B)%2 == 0:
    print(abs(A - B)//2)
else:
    print(min(A-1,N-B)+1+abs(A-B+1)//2)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
print(6-A-B)

Fixed submission:
A = int(input())
B = int(input())
print(6-A-B)
Buggy python submission (verdict: Time Limit Exceeded):
def bi(x):
    x = int(x)
    i = 0
    o = [0]*61
    while x > 0:
        o[i] = x % 2
        x //= 2
        i += 1
    return o

N = int(input())
A = list(map(bi,input().split()))

# print(*A,sep='\n')
a = 0
ruijoo = 1
bbb = 0
for h in range(61):
    B = [A[x][h] for x in range(N)]
    isOne = sum(B)
    isZero = N - isOne
    C = [isOne,isZero]
    bbb += sum([C[B[x]] for x in range(N)])*ruijoo
    ruijoo *= 2
    ruijoo %= 1000000007

bbb *= 500000004
bbb %= 1000000007
print(bbb)

Fixed submission:
def bi(x):
    x = int(x)
    i = 0
    o = [0]*61
    while x > 0:
        o[i] = x % 2
        x //= 2
        i += 1
    return o

N = int(input())
A = list(map(bi,input().split()))

# print(*A,sep='\n')
a = 0
ruijoo = 1
bbb = 0
B = [0]*N
h = 0
while h < 61:
    i = 0
    isOne = 0
    while i < N:
        aaaa = A[i][h]
        isOne += aaaa
        B[i] = aaaa
        i += 1
    isZero = N - isOne
    C = [isOne,isZero]
    bbbb = 0
    i = 0
    while i < N:
        bbbb += C[B[i]]
        i += 1
    bbbb *= ruijoo
    bbb += bbbb
    bbb %= 1000000007
    ruijoo *= 2
    ruijoo %= 1000000007
    h += 1

bbb *= 500000004
bbb %= 1000000007
print(bbb)

Buggy python submission (verdict: Time Limit Exceeded):
def bi(x):
    x = int(x)
    i = 0
    o = [0]*61
    while x > 0:
        o[i] = x % 2
        x //= 2
        i += 1
    return o

N = int(input())
A = list(map(bi,input().split()))

# print(*A,sep='\n')
a = 0
ruijoo = 1
bbb = 0
for h in range(61):
    B = list(map(lambda x: x[h],A))
    isZero = sum(map(lambda x: x == 0,B))
    isOne = sum(map(lambda x: x == 1,B))
    bbb += sum(map(lambda x:isZero if x else isOne,B))*ruijoo
    ruijoo *= 2
    ruijoo %= 1000000007

bbb *= 500000004
bbb %= 1000000007
print(bbb)

Fixed submission:
def bi(x):
    x = int(x)
    i = 0
    o = [0]*61
    while x > 0:
        o[i] = x % 2
        x //= 2
        i += 1
    return o

N = int(input())
A = list(map(bi,input().split()))

# print(*A,sep='\n')
a = 0
ruijoo = 1
bbb = 0
B = [0]*N
h = 0
while h < 61:
    i = 0
    isOne = 0
    while i < N:
        aaaa = A[i][h]
        isOne += aaaa
        B[i] = aaaa
        i += 1
    isZero = N - isOne
    C = [isOne,isZero]
    bbbb = 0
    i = 0
    while i < N:
        bbbb += C[B[i]]
        i += 1
    bbbb *= ruijoo
    bbb += bbbb
    bbb %= 1000000007
    ruijoo *= 2
    ruijoo %= 1000000007
    h += 1

bbb *= 500000004
bbb %= 1000000007
print(bbb)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N = int(input())
EhasV = [set() for x in range(N)]
EE = [0] * (N-1)
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    EE[i] = {a,b}
    EhasV[a].add(i)
    EhasV[b].add(i)

K = len(max(EhasV,key=len))
Vcolor = [set(range(1,K+1)) for x in range(N)]

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

q = deque()
q.append(0)
i = 1
while i:
    v1 = q.pop()
    i -= 1
    for e in EhasV[v1]:
        if Ecolor[e] != -1:
            continue
        color = Vcolor[v1].pop()
        Ecolor[e] = color
        edgeside = EE[e]
        edgeside.discard(v1)
        v2 = edgeside.pop()
        Vcolor[v2].discard(color)
        q.append(v2)
        i += 1

print(K)
i = 0
while i < N - 1:
    print(Ecolor[i])
    i += 1

Fixed submission:
from collections import deque

N = int(input())
EhasV = [set() for x in range(N)]
EhasVnums = [0] * N
EE = [0] * (N-1)
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    EE[i] = {a,b}
    EhasV[a].add(i)
    EhasV[b].add(i)
    EhasVnums[a] += 1
    EhasVnums[b] += 1

K = len(max(EhasV,key=len))
Vcolor = [set(range(1,EhasVnums[x]+1)) for x in range(N)]
Ecolor = [-1] * (N-1)

q = deque()
q.append(0)
while q:
    v1 = q.pop()
    for e in EhasV[v1]:
        if Ecolor[e] != -1:
            continue
        color = Vcolor[v1].pop()
        Ecolor[e] = color
        edgeside = EE[e]
        edgeside.discard(v1)
        v2 = edgeside.pop()
        Vcolor[v2].discard(color)
        q.append(v2)

print(*([K]+Ecolor),sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N = int(input())
EhasV = [set() for x in range(N)]
EE = [0] * (N-1)
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    EE[i] = {a,b}
    EhasV[a].add(i)
    EhasV[b].add(i)

K = len(max(EhasV,key=len))
Vcolor = [set(range(1,K+1)) for x in range(N)]

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

q = deque()
q.append(0)
while q:
    v1 = q.pop()
    for e in EhasV[v1]:
        if Ecolor[e] != -1:
            continue
        color = Vcolor[v1].pop()
        Ecolor[e] = color
        edgeside = EE[e]
        edgeside.discard(v1)
        v2 = edgeside.pop()
        Vcolor[v2].discard(color)
        q.append(v2)

print(*([K]+Ecolor),sep='\n')

Fixed submission:
from collections import deque

N = int(input())
EhasV = [set() for x in range(N)]
EhasVnums = [0] * N
EE = [0] * (N-1)
for i in range(N-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    EE[i] = {a,b}
    EhasV[a].add(i)
    EhasV[b].add(i)
    EhasVnums[a] += 1
    EhasVnums[b] += 1

K = len(max(EhasV,key=len))
Vcolor = [set(range(1,EhasVnums[x]+1)) for x in range(N)]
Ecolor = [-1] * (N-1)

q = deque()
q.append(0)
while q:
    v1 = q.pop()
    for e in EhasV[v1]:
        if Ecolor[e] != -1:
            continue
        color = Vcolor[v1].pop()
        Ecolor[e] = color
        edgeside = EE[e]
        edgeside.discard(v1)
        v2 = edgeside.pop()
        Vcolor[v2].discard(color)
        q.append(v2)

print(*([K]+Ecolor),sep='\n')
Buggy python submission (verdict: Runtime Error):
import math

a,b,x = map(int,input().split())

xdash = x / a
FULL = a * b

if FULL / 2 == xdash:
    print(math.degrees(math.atan2(b,a)))
elif FULL / 2 > xdash:
    print(90-math.degrees(math.atan(2*xdash/b/b)))
else:
    print(90-math.degrees(math.atan(a*a/2/(a*b-xdash))))


Fixed submission:
import math

a,b,x = map(int,input().split())

xdash = x / a
FULL = a * b

if xdash == FULL:
    print(0)
elif FULL / 2 == xdash:
    print(math.degrees(math.atan2(b,a)))
elif FULL / 2 > xdash:
    print(90-math.degrees(math.atan(2*xdash/b/b)))
else:
    print(90-math.degrees(math.atan(a*a/2/(a*b-xdash))))