Buggy python submission (verdict: Time Limit Exceeded):
from queue import Queue
N, M, K = map(int, input().split())
F = [[] for _ in range(N+1)]
B = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    F[a].append(b)
    F[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    B[c].append(d)
    B[d].append(c)

checked = [False] * (N+1)
checked[0] = True
ans = ['0'] * (N+1)
for v in range(1, N+1):
    if checked[v]:
        continue
    A = []
    q = Queue()
    for u in F[v]:
        q.put(u)

    while not q.empty():
        u = q.get()
        if checked[u]: continue
        A.append(u)
        for w in F[u]:
            q.put(w)
        checked[u] = True
    
    for a in A:
        ans[a] = str(len(A)-len(F[a])-1 - len(set(A)&set(B[a])))
    
    checked[v] = True

print(' '.join(ans[1:]))

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

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

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

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

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M, K = map(int, input().split())
uf = UnionFind(N+1)
F = [0] * (N+1)
B = [0] * (N+1)
for _ in range(M):
    a, b = map(int, input().split())
    uf.unite(a, b)
    F[a] += 1
    F[b] += 1

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

for i in range(1, N+1):
    ans = uf.size(i) - F[i] - B[i] - 1
    print(ans, end=' ')

print()

Buggy python submission (verdict: Time Limit Exceeded):
from queue import Queue
N, M, K = map(int, input().split())
F = [set([]) for _ in range(N+1)]
B = [set([]) for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    F[a].add(b)
    F[b].add(a)

for _ in range(K):
    c, d = map(int, input().split())
    B[c].add(d)
    B[d].add(c)

checked = [False] * (N+1)
checked[0] = True
ans = ['0'] * (N+1)
for v in range(1, N+1):
    if checked[v]:
        continue
    A = []
    q = Queue()
    for u in F[v]:
        q.put(u)

    while not q.empty():
        u = q.get()
        if checked[u]: continue
        A.append(u)
        for w in F[u]:
            q.put(w)
        checked[u] = True
    
    for a in A:
        ans[a] = str(len(set(A) - set(B[a]) - set(F[a]) - set([a])))
    
    checked[v] = True

print(' '.join(ans[1:]))

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

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

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

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

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M, K = map(int, input().split())
uf = UnionFind(N+1)
F = [0] * (N+1)
B = [0] * (N+1)
for _ in range(M):
    a, b = map(int, input().split())
    uf.unite(a, b)
    F[a] += 1
    F[b] += 1

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

for i in range(1, N+1):
    ans = uf.size(i) - F[i] - B[i] - 1
    print(ans, end=' ')

print()

Buggy python submission (verdict: Time Limit Exceeded):
from queue import Queue
N, M, K = map(int, input().split())
F = [set([]) for _ in range(N+1)]
B = [set([]) for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    F[a].add(b)
    F[b].add(a)

for _ in range(K):
    c, d = map(int, input().split())
    B[c].add(d)
    B[d].add(c)

checked = [False] * (N+1)
checked[0] = True
ans = ['0'] * (N+1)
for v in range(1, N+1):
    if checked[v]:
        continue
    A = []
    q = Queue()
    for u in F[v]:
        q.put(u)

    while not q.empty():
        u = q.get()
        if not checked[u]:
            A.append(u)
            for w in F[u]:
                q.put(w)
            checked[u] = True
    
    for a in A:
        ans[a] = str(len(set(A) - set(B[a]) - set(F[a]) - set([a])))
    
    checked[v] = True

print(' '.join(ans[1:]))

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

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

    def unite(self, u, v):
        u = self.find(u)
        v = self.find(v)

        if u == v:
            return

        if self.parents[u] > self.parents[v]:
            u, v = v, u

        self.parents[u] += self.parents[v]
        self.parents[v] = u

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

    def same(self, u, v):
        return self.find(u) == self.find(v)

N, M, K = map(int, input().split())
uf = UnionFind(N+1)
F = [0] * (N+1)
B = [0] * (N+1)
for _ in range(M):
    a, b = map(int, input().split())
    uf.unite(a, b)
    F[a] += 1
    F[b] += 1

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

for i in range(1, N+1):
    ans = uf.size(i) - F[i] - B[i] - 1
    print(ans, end=' ')

print()