Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

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

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

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

n, m, k = map(int, input().split())
uf = UnionFind(n)

friend = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	friend[a-1].append(b-1)
	friend[b-1].append(a-1)
	uf.unite(a-1, b-1)

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

ans = []
for i in range(n):
	res = uf.get_size(i) - 1 - len(friend[i])
	for v in block[i]:
		if uf.find(i) == uf.find(v):
			res -= 1
	ans.append(res)

print(*ans)

Fixed submission:
import sys
def input():
	return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

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

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

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

n, m, k = map(int, input().split())
uf = UnionFind(n)

friend = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	friend[a-1].append(b-1)
	friend[b-1].append(a-1)
	uf.unite(a-1, b-1)

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

ans = []
for i in range(n):
	res = uf.get_size(i) - 1 - len(friend[i])
	for v in block[i]:
		if uf.find(i) == uf.find(v):
			res -= 1
	ans.append(res)

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
	return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

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

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

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

n, m, k = map(int, input().split())
uf = UnionFind(n)

friend = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	friend[a-1].append(b-1)
	friend[b-1].append(a-1)
	uf.unite(a-1, b-1)

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

ans = []
for i in range(n):
	res = uf.get_size(i) - 1 - len(friend[i])
	for v in block[i]:
		if uf.find(i) == uf.find(v):
			res -= 1
	ans.append(res)

print(*ans)

Fixed submission:
import sys
def input():
	return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10 ** 6)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

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

	def unite(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

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

n, m, k = map(int, input().split())
uf = UnionFind(n)

friend = [[] for _ in range(n)]
for _ in range(m):
	a, b = map(int, input().split())
	friend[a-1].append(b-1)
	friend[b-1].append(a-1)
	uf.unite(a-1, b-1)

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

ans = []
for i in range(n):
	res = uf.get_size(i) - 1 - len(friend[i])
	for v in block[i]:
		if uf.find(i) == uf.find(v):
			res -= 1
	ans.append(res)

print(*ans)