Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
relate = [[0] * N for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    relate[a][b] = 1
    relate[b][a] = 1
from collections import deque
# g : グラフ
# 例 [[1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8]]
# i : 始点
def bfs(s):

    #訪れたかどうか
    d = [False] * N
    #初期設定
    que = deque()
    que.append(relate[s])
    d[s] = True
    
    while que:
        p = que.popleft()
        for i, j in enumerate(p):
            if j == 0 or d[i]:
                continue
            else:
                d[i] = True
                que.append(relate[i])
    return d
import copy
d = [bfs(i) for i in range(N)]
block_d = copy.deepcopy(d)
for i in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    block_d[a][b] = 0
    block_d[b][a] = 0
for i in range(N):
    d[i][i] = 0
    block_d[i][i] = 0
    print(sum(block_d[i]) - sum(relate[i]))


Fixed submission:
N, M, K = map(int, input().split())
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())

d = UnionFind(N)
num_fri = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    d.union(a - 1, b - 1)
    num_fri[a - 1] += 1
    num_fri[b - 1] += 1
#num = [d.size(i) for i in range(N)]
for i in range(K):
    a, b = map(int, input().split())
    if d.same(a - 1, b - 1):
        num_fri[a - 1] += 1
        num_fri[b - 1] += 1
for i in range(N):
    print((d.size(i) - 1) - num_fri[i], end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
relate = [[0] * N for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    relate[a][b] = 1
    relate[b][a] = 1
from collections import deque
# g : グラフ
# 例 [[1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8]]
# i : 始点
def bfs(s):

    #訪れたかどうか
    d = [False] * N
    #初期設定
    que = deque()
    que.append(relate[s])
    d[s] = True
    
    while que:
        p = que.popleft()
        for i, j in enumerate(p):
            if j == 0 or d[i]:
                continue
            else:
                d[i] = True
                que.append(relate[i])
    return d
import copy
d = [bfs(i) for i in range(N)]
block_d = copy.deepcopy(d)
for i in range(K):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    block_d[a][b] = 0
    block_d[b][a] = 0
for i in range(N):
    d[i][i] = 0
    block_d[i][i] = 0
    print(sum(block_d[i]) - sum(relate[i]))

Fixed submission:
N, M, K = map(int, input().split())
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())

d = UnionFind(N)
num_fri = [0] * N
for i in range(M):
    a, b = map(int, input().split())
    d.union(a - 1, b - 1)
    num_fri[a - 1] += 1
    num_fri[b - 1] += 1
#num = [d.size(i) for i in range(N)]
for i in range(K):
    a, b = map(int, input().split())
    if d.same(a - 1, b - 1):
        num_fri[a - 1] += 1
        num_fri[b - 1] += 1
for i in range(N):
    print((d.size(i) - 1) - num_fri[i], end=' ')