Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M,K = list(map(int,input().split()))
G1 = [[] for i in range(N)]
G2 = [[] for i in range(N)]
for i in range(M):
    A,B = list(map(int,input().split()))
    G1[A-1].append(B-1)
    G1[B-1].append(A-1)

for i in range(K):
    A,B = list(map(int,input().split()))
    G2[A-1].append(B-1)
    G2[B-1].append(A-1)

Block = [0]*N
Friend = [0]*N
Network = [0]*N
out = [0]*N

for i in range(N):
    Friend[i] = len(G1[i])

Done = [0]*N
for i in range(N):
    s = i
    if Done[s]!=0:
        continue
    L = []
    que = deque([s])
    Done[s] = 1
    L.append(s)
    while que:
        v = que.popleft()
        for w in G1[v]:
            if Done[w]==1:
                continue
            Done[w] = 1
            que.append(w)
            L.append(w)
    NL = len(L)
    for j in L:
        Network[j] = NL-1
        Block[j] = len(set(L)&set(G2[j]))

for i in range(N):
    out[i] = Network[i]-Block[i]-Friend[i]
print(*out)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
Network = UnionFind(N)
Friend = [0] * N
BlockInNetwork = [0] * N

for _ in range(M):
    a, b = map(int, input().split())
    Network.union(a-1, b-1)
    Friend[a-1] += 1
    Friend[b-1] += 1

for _ in range(K):
    c, d = map(int, input().split())
    if Network.same(c-1, d-1):
        BlockInNetwork[c-1] += 1
        BlockInNetwork[d-1] += 1

out = [0]*N
for i in range(N):
    out[i]=Network.size(i)-Friend[i]-BlockInNetwork[i] - 1
print(*out)

Buggy python submission (verdict: Runtime Error):
[N,M,K] = list(map(int,input().split()))

F = [[] for i in range(N)]
B = [[] for i in range(N)]

for i in range(M):
    [A0,B0] = list(map(int,input().split()))
    F[A0-1].append(B0)
    F[B0-1].append(A0)
for i in range(K):
    [C0,D0] = list(map(int,input().split()))
    B[C0-1].append(D0)
    B[D0-1].append(C0)


def check(X,L):
    for i in F[X]:
        if ch[i-1]==0:
            ch[i-1]=1
            L.append(i)
            check(i-1,L)
X = []
ch = [0]*N
t = 0
while True:
    if t==N:
        break
    L0 = []
    L0.append(t+1)
    ch[t]=1
    check(t,L0)
    X.append(L0)
    while (t<N)and(ch[t]==1):
        t+=1
output = [0]*N
for i in range(len(X)):
    for j in X[i]:
        output[j-1] = len(X[i]) - len(F[j-1]) - len(set(B[j-1])&set(X[i]))-1

st = ""
for i in range(N-1):
    st += str(output[i]) + " "
st += str(output[N-1])
print(st)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
Network = UnionFind(N)
Friend = [0] * N
BlockInNetwork = [0] * N

for _ in range(M):
    a, b = map(int, input().split())
    Network.union(a-1, b-1)
    Friend[a-1] += 1
    Friend[b-1] += 1

for _ in range(K):
    c, d = map(int, input().split())
    if Network.same(c-1, d-1):
        BlockInNetwork[c-1] += 1
        BlockInNetwork[d-1] += 1

out = [0]*N
for i in range(N):
    out[i]=Network.size(i)-Friend[i]-BlockInNetwork[i] - 1
print(*out)

Buggy python submission (verdict: Runtime Error):
[N,M,K] = list(map(int,input().split()))

F = [[] for i in range(N)]
B = [[] for i in range(N)]

for i in range(M):
    [A0,B0] = list(map(int,input().split()))
    F[A0-1].append(B0)
    F[B0-1].append(A0)
for i in range(K):
    [C0,D0] = list(map(int,input().split()))
    B[C0-1].append(D0)
    B[D0-1].append(C0)


def check(X,L):
    for i in F[X]:
        if ch[i-1]==0:
            ch[i-1]=1
            L.append(i)
            check(i-1,L)
X = []
ch = [0]*N
t = 0
while True:
    if t==N:
        break
    L0 = []
    L0.append(t+1)
    ch[t]=1
    check(t,L0)
    X.append(L0)
    while (t<N)and(ch[t]==1):
        t+=1
output = [0]*N
for i in range(len(X)):
    for j in X[i]:
        output[j-1] = len(X[i]) - len(F[j-1]) - len(set(B[j-1])&set(X[i]))-1

st = ""
for i in range(N-1):
    st += str(output[i]) + " "
st += str(output[N-1])
print(st)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M, K = map(int, input().split())
Network = UnionFind(N)
Friend = [0] * N
BlockInNetwork = [0] * N

for _ in range(M):
    a, b = map(int, input().split())
    Network.union(a-1, b-1)
    Friend[a-1] += 1
    Friend[b-1] += 1

for _ in range(K):
    c, d = map(int, input().split())
    if Network.same(c-1, d-1):
        BlockInNetwork[c-1] += 1
        BlockInNetwork[d-1] += 1

out = [0]*N
for i in range(N):
    out[i]=Network.size(i)-Friend[i]-BlockInNetwork[i] - 1
print(*out)