Problem:
 Score : 400 points    Problem Statement An SNS has N users - User 1 , User 2 , \cdots , User N .  Between these N users, there are some relationships - M  friendships and K  blockships .  For each i = 1, 2, \cdots, M , there is a bidirectional friendship between User A_i and User B_i .  For each i = 1, 2, \cdots, K , there is a bidirectional blockship between User C_i and User D_i .  We define User a to be a friend candidate for User b when all of the following four conditions are satisfied:   a \neq b .  There is not a friendship between User a and User b .  There is not a blockship between User a and User b .  There exists a sequence c_0, c_1, c_2, \cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a , c_L = b , and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \cdots, L - 1 .   For each user i = 1, 2, ... N , how many friend candidates does it have?      Constraints  All values in input are integers.  2 ≤ N ≤ 10^5  0 \leq M \leq 10^5  0 \leq K \leq 10^5  1 \leq A_i, B_i \leq N  A_i \neq B_i  1 \leq C_i, D_i \leq N  C_i \neq D_i  (A_i, B_i) \neq (A_j, B_j) (i \neq j)  (A_i, B_i) \neq (B_j, A_j)  (C_i, D_i) \neq (C_j, D_j) (i \neq j)  (C_i, D_i) \neq (D_j, C_j)  (A_i, B_i) \neq (C_j, D_j)  (A_i, B_i) \neq (D_j, C_j)         Input Input is given from Standard Input in the following format:  N  M  K  A_1  B_1  \vdots  A_M  B_M  C_1  D_1  \vdots  C_K  D_K       Output Print the answers in order, with space in between.        Sample Input 1 4 4 1
2 1
1 3
3 2
3 4
4 1      Sample Output 1 0 1 0 1  There is a friendship between User 2 and 3 , and between 3 and 4 . Also, there is no friendship or blockship between User 2 and 4 . Thus, User 4 is a friend candidate for User 2 .  However, neither User 1 or 3 is a friend candidate for User 2 , so User 2 has one friend candidate.       Sample Input 2 5 10 0
1 2
1 3
1 4
1 5
3 2
2 4
2 5
4 3
5 3
4 5      Sample Output 2 0 0 0 0 0  Everyone is a friend of everyone else and has no friend candidate.       Sample Input 3 10 9 3
10 1
6 7
8 2
2 5
8 4
7 3
10 9
6 4
5 8
2 6
7 5
3 1      Sample Output 3 1 3 5 4 3 3 3 3 1 0

Solution (Python):
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())
friend=[[] for _ in range(n)]
block=[[] for _ in range(n)]
a=UnionFind(n)
for i in range(m):
    x,y=map(int,input().split())
    friend[x-1].append(y-1)
    friend[y-1].append(x-1)
    a.union(x-1,y-1)
for i in range(k):
    x,y=map(int,input().split())
    block[x-1].append(y-1)
    block[y-1].append(x-1)
ans=[]
for i in range(n):
    ans.append(a.size(i)-len(friend[i])-sum(a.same(i,j) for j in block[i])-1)
print(*ans)

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,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())

def do():
    n,m,k=INTM()
    uf=UnionFind(n)
    fri=[[] for i in range(n)]
    blo=[[] for i in range(n)]
    for i in range(m):
        a,b=INTM()
        a-=1
        b-=1
        fri[a].append(b)
        fri[b].append(a)
        uf.union(a,b)
    for i in range(k):
        c,d=INTM()
        c-=1
        d-=1
        blo[c].append(d)
        blo[d].append(c)

    ans=[]

    for i in range(n):
        blos=0
        for j in blo[i]:
            if uf.same(i,j):
                blos+=1
        
        ans.append(uf.size(i)-1-len(fri[i])-blos)
    
    print(*ans)




if __name__=='__main__':
    do()

Solution (Python):
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())
c = [0] * (N + 1)
C = [0] * K
D = [0] * K
uf = UnionFind(N)

for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    c[a] += 1
    c[b] += 1
for i in range(K):
    C[i], D[i] = map(int, input().split())


for i in range(1,N + 1):
    c[i] = uf.size(i-1) - c[i] - 1
for i in range(K):
    if uf.same(C[i]-1, D[i]-1):
        c[C[i]] -= 1
        c[D[i]] -= 1

for i in range(1, N+1):
    print(c[i], end=" ")

Solution (Python):
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)

n,m,k=map(int,input().split())
uf=UnionFind(n)
friend=[[] for _ in range(n)]
brock=[[] for _ in range(n)]
ans=[]
for _ in range(m):
    a,b=map(int,input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
    uf.union(a-1,b-1)
for _ in range(k):
    c,d=map(int,input().split())
    brock[c-1].append(d-1)
    brock[d-1].append(c-1)
for i in range(n):
    ans.append(uf.size(i)-len(friend[i])-sum([uf.same(i,j) for j in brock[i]])-1)
print(*ans)

Solution (Python):
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())
uf=UnionFind(n)
edge=[[] for _ in range(n)]
brock=[[] for _ in range(n)]
ans=[]
for _ in range(m):
    a,b=map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    uf.union(a-1,b-1)
for _ in range(k):
    c,d=map(int,input().split())
    brock[c-1].append(d-1)
    brock[d-1].append(c-1)
for i in range(n):
    ans.append(uf.size(i)-len(edge[i])-sum([uf.same(i,j) for j in brock[i]])-1)
print(*ans)

Solution (Python):
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())

def main():
    N, M, K = map(int, input().split())
    friend = UnionFind(N)
    direct_friend = [0] * N
    block = [0] * N

    for _ in range(M):
        a, b = map(int, input().split())
        friend.union(a-1, b-1)
        direct_friend[a-1] += 1
        direct_friend[b-1] += 1
    
    for _ in range(K):
        c, d = map(int, input().split())
        if friend.same(c-1, d-1):
            block[c-1] += 1
            block[d-1] += 1

    for i in range(N):
        print(friend.size(i) - direct_friend[i] - block[i] - 1, end=" ")

if __name__ == "__main__":
    main()

Solution (Python):
n,m,k=map(int,input().split())

class UnionFind:
    def __init__(self,n):
        self.ps = [-1]*(n+1)
    def find(self,x):
        if self.ps[x]<0:
            return x
        else:
            self.ps[x]=self.find(self.ps[x])
            return self.ps[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return False
        if self.ps[x]>self.ps[y]:
            x,y = y,x
        self.ps[x] += self.ps[y]
        self.ps[y] = x
        return True
    def same(self,x,y):
        return self.find(x)==self.find(y)
    def size(self,x):
        x = self.find(x)
        return -self.ps[x]

all1 = [0]*(n)

uf = UnionFind(n)
for i in range(m):
    a,b = map(int,input().split())
    uf.unite(a,b)
    a,b = a-1,b-1
    
    all1[a] +=1
    all1[b] +=1

ans = [uf.size(x)-1-all1[x-1] for x in range(1,n+1)]


for i in range(k):
    a,b = map(int,input().split())
    if uf.same(a,b):
        a,b = a-1,b-1
        ans[a] -=1
        ans[b] -=1
print(*ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
n,m,k=map(int,input().split())
friend=[[] for _ in range(n)]
block=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friend[a].append(b)
    friend[b].append(a)
for _ in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    block[c].append(d)
    block[d].append(c)
seen=[-1]*n
def dfs(graph,v,top):
    seen[v]=top
    top_count[top]+=1
    for nv in graph[v]:
        if seen[nv]!=-1:
            continue
        dfs(graph,nv,top)
top=0
top_count=[0]
for v in range(n):
    count=0
    if seen[v]!=-1:
        continue
    dfs(friend,v,top)
    top_count.append(0)
    top+=1


for i in range(n):
    ans=top_count[seen[i]]-len(friend[i])-1
    cnt=0
    for v in block[i]:
        if seen[v]==seen[i]:
            cnt+=1
    ans-=cnt
    print(ans,end=' ')

Solution (Python):
N,M,K=map(int,input().split())
par=[0]*(N+1)
num=[0]*(N+1)
group = [1]*(N+1)

for i in range(1,N+1): par[i]=i

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

def union(x,y):
  rx = root(x)
  ry = root(y)
  if rx==ry: return
  par[max(rx,ry)] = min(rx,ry)
  group[min(rx,ry)] += group[max(rx,ry)]

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

for _ in range(M):
  a,b=map(int,input().split())
  union(a,b)
  num[a]+=1
  num[b]+=1
for _ in range(K):
  c,d=map(int,input().split())
  if same(c,d):
    num[c]+=1
    num[d]+=1

for i in range(1,N+1):
  print(group[root(i)]-num[i]-1,end=" ")

Solution (Python):
N,M,K=map(int,input().split())
par=[0]*(N+1)
num=[0]*(N+1)
group = [1]*(N+1)

for i in range(1,N+1): par[i]=i

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

def union(x,y):
  rx = root(x)
  ry = root(y)
  if rx==ry: return
  par[max(rx,ry)] = min(rx,ry)
  group[min(rx,ry)] += group[max(rx,ry)]

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

for _ in range(M):
  a,b=map(int,input().split())
  union(a,b)
  num[a]+=1
  num[b]+=1
for _ in range(K):
  c,d=map(int,input().split())
  if same(c,d):
    num[c]+=1
    num[d]+=1

for i in range(1,N+1):
  print(group[root(i)]-num[i]-1,end=" ")

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


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.size = [1 for i in range(n)]

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])
        return self.par[x]

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

        if x == y:
            return
        if self.size[x] > self.size[y]:
            x, y = y, x
        self.par[x] = y
        self.size[y] += self.size[x]


uf = UnionFind(N)
fri = []
rst = [0]*N

for m in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    fri.append((A, B))
    uf.unite(A, B)

for i in range(N):
    ind = uf.find(i)
    rst[i] = uf.size[ind]-1

for f in fri:
    A, B = f
    if uf.par[A] == uf.par[B]:
        rst[A] -= 1
        rst[B] -= 1

for k in range(K):
    C, D = map(int, input().split())
    C -= 1
    D -= 1
    if uf.par[C] == uf.par[D]:
        rst[C] -= 1
        rst[D] -= 1

print(" ".join(map(str, rst)))

Solution (Python):
"""/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Union-Find！Union-Find！Union-Find！Union-Findぅぅうううわぁああああああああああああああああああああああん！！！
あぁああああ…ああ…あっあっー！あぁああああああ！！！Union-FindUnion-FindUnion-Findぅううぁわぁああああ！！！
あぁクンカクンカ！クンカクンカ！スーハースーハー！スーハースーハー！いい匂いだなぁ…くんくん
んはぁっ！Union-Findたんの桃色ブロンドの髪をクンカクンカしたいお！クンカクンカ！あぁあ！！
間違えた！モフモフしたいお！モフモフ！モフモフ！髪髪モフモフ！カリカリモフモフ…きゅんきゅんきゅい！！
小説12巻のUnion-Findたんかわいかったよぅ！！あぁぁああ…あああ…あっあぁああああ！！ふぁぁあああんんっ！！
アニメ2期放送されて良かったねUnion-Findたん！あぁあああああ！かわいい！Union-Findたん！かわいい！あっああぁああ！
コミック2巻も発売されて嬉し…いやぁああああああ！！！にゃああああああああん！！ぎゃああああああああ！！
ぐあああああああああああ！！！コミックなんて現実じゃない！！！！あ…小説もアニメもよく考えたら…
U n i o n - F i n d ち ゃ ん は 現 実 じ ゃ な い？にゃあああああああああああああん！！うぁああああああああああ！！
そんなぁああああああ！！いやぁぁぁあああああああああ！！はぁああああああん！！う　し　た　ぷ　に　き　あ　王　国　笑ぁああああ！！
この！ちきしょー！やめてやる！！現実なんかやめ…て…え！？見…てる？表紙絵のUnion-Findちゃんが僕を見てる？
表紙絵のUnion-Findちゃんが僕を見てるぞ！Union-Findちゃんが僕を見てるぞ！挿絵のUnion-Findちゃんが僕を見てるぞ！！
アニメのUnion-Findちゃんが僕に話しかけてるぞ！！！よかった…世の中まだまだ捨てたモンじゃないんだねっ！
いやっほぉおおおおおおお！！！僕にはUnion-Findちゃんがいる！！やったよdefault dict！！ひとりでできるもん！！！
あ、コミックのUnion-Findちゃああああああああああああああん！！いやぁあああああああああああああああ！！！！
あっあんああっああんあset様ぁあ！！さ、最小全域木ー！！Dijkstraぁああああああ！！！セグ木ぃいいい！！
ううっうぅうう！！俺の想いよUnion-Findへ届け！！う　し　た　ぷ　に　き　あ　王　国　笑のUnion-Findへ届け！
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////"""
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n
    def find(self, x):
        if self.parents[x] == x:
            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.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[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())
uf=UnionFind(n)
friends=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    friends[a-1]+=1
    friends[b-1]+=1
block=[[] for _ in range(n)]
for i in range(k):
    c,d=map(int,input().split())
    block[c-1].append(d)
    block[d-1].append(c)
ans=[0]*n
cnt=[0]*n
for i in range(n):
    cnt[i]=uf.find(i)
for i in range(n):
    num1=uf.size[uf.find(i)]-friends[i]-1
    num2=cnt[i]
    for j in range(len(block[i])):
        if num2==cnt[block[i][j]-1]:
            num1-=1
    ans[i]=num1
print(*ans)

Solution (Python):
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n
    def find(self, x):
        if self.parents[x] == x:
            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.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[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())
uf=UnionFind(n)
friends=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    friends[a-1]+=1
    friends[b-1]+=1
block=[[] for _ in range(n)]
for i in range(k):
    c,d=map(int,input().split())
    block[c-1].append(d)
    block[d-1].append(c)
ans=[0]*n
cnt=[0]*n
for i in range(n):
    cnt[i]=uf.find(i)
for i in range(n):
    num1=uf.size[uf.find(i)]-friends[i]-1
    num2=cnt[i]
    for j in range(len(block[i])):
        if num2==cnt[block[i][j]-1]:
            num1-=1
    ans[i]=num1
print(*ans)

Solution (Python):
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())
suggest = UnionFind(n)
follow = [0]*n
block = [0]*n
for i in range(n):
    follow[i] = list()
    block[i]  = list()
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    suggest.union(a,b)
    follow[a].append(b)
    follow[b].append(a)

for _ in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    block[c].append(d)
    block[d].append(c)
ans = ""
suggestfriend = [0]*n
ans = ""
for i in range(n):
    blockperson = 0
    union = suggest.size(i)
    for j in range(len(block[i])):
        if(suggest.same(i,block[i][j])):
            blockperson += 1
    ans += str(union - blockperson -len(follow[i]) - 1) + " "
print(ans)

Solution (Python):
class UnionFind():
  def __init__(self,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)]


N,M,K=map(int,input().split())
uf=UnionFind(N+1)
friends={x:set() for x in range(1,N+1)}
blocks={x:set() for x in range(1,N+1)}
ans=[N-1]*(N+1)

for _ in range(M):
  A,B=map(int,input().split())
  friends[A].add(B)
  friends[B].add(A)
  uf.union(A,B)

for _ in range(K):
  C,D=map(int,input().split())
  if uf.find(C)==uf.find(D):
    blocks[C].add(D)
    blocks[D].add(C)

for i in range(1,N+1):
  if uf.size(i)==-1:
    print(0)
    continue
  print(abs(uf.size(i))-len(friends[i])-len(blocks[i])-1,end=' ')

Solution (Python):
class Union_Find:
  def __init__(self,n=0):
    self.vertices=n
    self.mother=[-1 for i in range(self.vertices)]
    self.size_temp=[1 for i in range(self.vertices)]
  
  def root(self,x):
    normalize_v=[]
    while x!=-1:
      normalize_v.append(x)
      y=x
      x=self.mother[x]
    for i in normalize_v[:-1]:
      self.mother[i]=y
    return y
  
  def union(self,x,y):
    root_x=self.root(x)
    root_y=self.root(y)
    if root_x!=root_y:
      self.mother[root_x]=root_y
      self.size_temp[root_y]+=self.size_temp[root_x]
  
  def find(self,x,y):
    if self.root(x)==self.root(y):
      return True
    else:
      return False
  
  def size(self,x):
    return self.size_temp[self.root(x)]



n,m,k=map(int,input().split())
uf=Union_Find(n)
friend=[0 for i in range(n)]
block=[[] for i in range(n)]

for i in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  friend[a]+=1
  friend[b]+=1
  uf.union(a,b)

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

r=""
for i in range(n):
  size=uf.size(i)
  size-=friend[i]
  for j in block[i]:
    if uf.find(i,j):
      size-=1
  r+=str(size-1)+" "
print(r[:-1])

Solution (Python):
class DisjointSets:
    def __init__(self, n):
        self.nodes = [-1] * n 
    def find(self, i):
        if self.nodes[i] < 0: 
            return i
        else:
            self.nodes[i] = self.find(self.nodes[i]) 
            return self.nodes[i]
    def unite(self, i, j):
        i = self.find(i)
        j = self.find(j)
        if i == j:
            return
        if self.nodes[i] > self.nodes[j]: 
            i, j = j, i
        self.nodes[i] += self.nodes[j] 
        self.nodes[j] = i 
    
    def size(self, i): 
        i = self.find(i)
        return -self.nodes[i]

n, m, k = map(int, input().split())
ds = DisjointSets(n)
friends_count = [0] * n

for _ in range(m):
    a, b = map(lambda x:int(x)-1, input().split())
    friends_count[a] += 1
    friends_count[b] += 1
    ds.unite(a, b)
block_count = [0] * n
for _ in range(k):
    a, b = map(lambda x:int(x)-1, input().split())
    if ds.find(a) == ds.find(b):
        block_count[a] += 1
        block_count[b] += 1

print(' '.join([str(ds.size(i) - friends_count[i] - block_count[i] - 1) for i in range(n)]))

Solution (Python):
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    def unite(self, x, y):
        x = self.find(x); y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    def group_size(self, x):
        return self.size[self.find(x)]
n, m, k = map(int, input().split())
a = [0]*m; b = [0]*m; c = [0]*k; d = [0]*k; x = [0]*n
direct = [[] for _ in range(n)]; uf = UnionFind(n)
for i in range(m):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1; b[i] -= 1
    direct[a[i]].append(b[i]); direct[b[i]].append(a[i])
    uf.unite(a[i], b[i])
for i in range(k):
    c[i], d[i] = map(int, input().split())
    c[i] -= 1; d[i] -= 1
    if uf.is_same(c[i], d[i]):
        direct[c[i]].append(d[i]); direct[d[i]].append(c[i])
for i in range(n): x[i] = uf.group_size(i)-len(direct[i])-1
print(*x)

Solution (Python):

import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N, M, K = MI()
    friends = [[] for i in range(N)]
    blocks = [[] for i in range(N)]

    for _ in range(M):
        a, b = MI()
        a -= 1
        b -= 1
        friends[a].append(b)
        friends[b].append(a)

    for _ in range(K):
        a, b = MI()
        a -= 1
        b -= 1
        blocks[a].append(b)
        blocks[b].append(a)

    flag = [-1] * N
    group = 0
    for i in range(N):
        if flag[i] != -1:
            continue
        deque = cl.deque(friends[i])
        flag[i] = group
        while len(deque) > 0:
            target = deque.popleft()
            flag[target] = group
            friends_i = friends[target]
            for frend in friends_i:
                if flag[frend] != -1:
                    continue
                flag[frend] = group
                deque.append(frend)
        group += 1

    groups = [[] for i in range(N)]
    for i in range(len(flag)):
        groups[flag[i]].append(i)
    ans = []
    for i in range(len(groups)):
        groups[i] = set(groups[i])

    for i in range(N):
        i_group = flag[i]
        candidate = len(groups[i_group]) - len(friends[i]) - 1
        for blocking in blocks[i]:
            if blocking in groups[i_group]:
                candidate -= 1
        ans.append(candidate)
    print(" ".join(map(str, ans)))


main()

Solution (Python):
n, m, k = map(int, input().split())
friendships = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  friendships[a-1].append(b-1)
  friendships[b-1].append(a-1)
blockships = [[] for _ in range(n)]
for _ in range(k):
  c, d = map(int, input().split())
  blockships[c-1].append(d-1)
  blockships[d-1].append(c-1)


component_id = [-1]*n
component_size = dict()
stack_to_visit = [(node, node) for node in range(n)]
while stack_to_visit:
  node, parent_id = stack_to_visit.pop()
  if component_id[node] != -1:
    continue
  component_id[node] = parent_id
  component_size[parent_id] = component_size.get(parent_id, 0) + 1
  for other in friendships[node]:
    stack_to_visit.append((other, parent_id))

for node in range(n):
  suggestions = 0
  current_id = component_id[node]
  suggestions += component_size[current_id] - 1
  suggestions -= len(friendships[node])
  suggestions -= sum(int(component_id[other] == current_id) for other in blockships[node])
  print(suggestions, end=" ")

Solution (Python):
import sys


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

    def _root(self, x):
        stack = []
        tbl = self.table
        while tbl[x] >= 0:
            stack.append(x)
            x = tbl[x]
        for y in stack:
            tbl[y] = x
        return x

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

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1


def main():
    n, m, k = map(int, sys.stdin.buffer.readline().split())
    uf = UnionFind(n)
    fb = [0]*n
    i = 0
    for x in sys.stdin.buffer.readlines():
        if i < m:
            a, b = map(int, x.split())
            fb[a-1] += 1
            fb[b-1] += 1
            uf.union(a-1, b-1)
        else:
            c, d = map(int, x.split())
            if uf._root(c-1) == uf._root(d-1):
                fb[c-1] += 1
                fb[d-1] += 1
        i += 1

    ans = [-uf.table[uf._root(i)]-1-fb[i] for i in range(n)]
    print(*ans)


if __name__ == "__main__":
    main()