CodeEff/ECCO huggingface dataset:
# Original solution
import sys
input = lambda: sys.stdin.readline().rstrip()

#https://www.slideshare.net/chokudai/union-find-49066733
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * self.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 False
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
        
  def issame(self, x, y):
    return self.find(x) == self.find(y)
  
  def get_node_members(self):
    return [[j for j in range(self.n) if self.issame(i, j)] for i in range(self.n)]
  
  def size(self, x):
    return -self.parents[self.find(x)]
  
N = list(map(int, input().split()))
uf = UnionFind(N[0])
results = [0 for i in range(N[0])]
for i in range(N[1]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  results[x] += 1
  results[y] += 1
  uf.union(x, y)
#print(uf.parents)

for i in range(N[2]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  if uf.issame(x, y):
  	results[x] += 1
  	results[y] += 1
  
node_members = uf.get_node_members()
#print(node_members, results)

print((" ".join([str(uf.size(i) - results[i] - 1) for i in range(N[0])])))

# Optimized solution
import sys
input = lambda: sys.stdin.readline()

#https://www.slideshare.net/chokudai/union-find-49066733
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * self.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 False
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
        
  def issame(self, x, y):
    return self.find(x) == self.find(y)
  
  def get_node_members(self):
    return [[j for j in range(self.n) if self.issame(i, j)] for i in range(self.n)]
  
  def size(self, x):
    return -self.parents[self.find(x)]
  
N = list(map(int, input().split()))
uf = UnionFind(N[0])
results = [0 for i in range(N[0])]
for i in range(N[1]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  results[x] += 1
  results[y] += 1
  uf.union(x, y)
#print(uf.parents)

for i in range(N[2]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  if uf.issame(x, y):
  	results[x] += 1
  	results[y] += 1
  
node_members = uf.get_node_members()
#print(node_members, results)

print((" ".join([str(uf.size(i) - results[i] - 1) for i in range(N[0])])))
# Original solution
import sys
input = lambda: sys.stdin.readline()

#https://www.slideshare.net/chokudai/union-find-49066733
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * self.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 False
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
        
  def issame(self, x, y):
    return self.find(x) == self.find(y)
  
  def get_node_members(self):
    return [[j for j in range(self.n) if self.issame(i, j)] for i in range(self.n)]
  
  def size(self, x):
    return -self.parents[self.find(x)]
  
N = list(map(int, input().split()))
uf = UnionFind(N[0])
results = [0 for i in range(N[0])]
for i in range(N[1]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  results[x] += 1
  results[y] += 1
  uf.union(x, y)
#print(uf.parents)

for i in range(N[2]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  if uf.issame(x, y):
  	results[x] += 1
  	results[y] += 1
  
node_members = uf.get_node_members()
#print(node_members, results)

print((" ".join([str(uf.size(i) - results[i] - 1) for i in range(N[0])])))


# Optimized solution
import sys
input = lambda: sys.stdin.readline().rstrip()

#https://www.slideshare.net/chokudai/union-find-49066733
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * self.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 False
    if self.parents[x] > self.parents[y]:
      x, y = y, x
    self.parents[x] += self.parents[y]
    self.parents[y] = x
        
  def issame(self, x, y):
    return self.find(x) == self.find(y)
  
  def get_node_members(self):
    return [[j for j in range(self.n) if self.issame(i, j)] for i in range(self.n)]
  
  def size(self, x):
    return -self.parents[self.find(x)]

N = list(map(int, input().split()))
parents = [-1] * N[0]
def find(x):
  if parents[x] < 0:
    return x
  else:
    parents[x] = find(parents[x])
    return parents[x]

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

  if x == y: return False
  if parents[x] > parents[y]:
    x, y = y, x
  parents[x] += parents[y]
  parents[y] = x
        
def issame(x, y):
  return find(x) == find(y)
  
def size(x):
  return -parents[find(x)]
  

results = [0 for i in range(N[0])]
for i in range(N[1]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  results[x] += 1
  results[y] += 1
  union(x, y)
#print(uf.parents)

for i in range(N[2]):
  x, y = list(map(int, input().split()))
  x, y = x - 1, y - 1
  if issame(x, y):
  	results[x] += 1
  	results[y] += 1
  
#print(node_members, results)

print((" ".join([str(size(i) - results[i] - 1) for i in range(N[0])])))
# Original solution


from collections import defaultdict
n, m, k = list(map(int, input().split()))
ns = defaultdict(set)
bs = defaultdict(set)
for i in range(m):
    a,b = list(map(int, input().split()))
    ns[a-1].add(b-1)
    ns[b-1].add(a-1)
for i in range(k):
    c,d = list(map(int, input().split()))
    bs[c-1].add(d-1)
    bs[d-1].add(c-1)
    
s = [0]
start = 0
parent = [None] * n
starts = defaultdict(int)
starts[0] = 0
notdone = set(list(range(n)))
notdone.remove(start)
while notdone or s:
    u = s.pop()
    parent[u] = start
    starts[start] += 1
    for v in ns[u]:
        if v in notdone:
            s.append(v)
            notdone.remove(v)
    if not s and notdone:
        start = notdone.pop()
        parent[start] = start
        s.append(start)
ans = [None] * n
for u in range(n):
    val = starts[parent[u]] - 1 - len(ns[u])
    for v in bs[u]:
        if parent[v]==parent[u]:
            val -= 1
    ans[u] = val
print((" ".join(map(str, ans))))

# Optimized solution
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m,k = list(map(int, input().split()))
class UnionFindTree:
    def __init__(self, n):
        self.n = n
        self.parent = list(range(n))
        self.size = [1] * n

    def root(self, i):
        inter = set()
        while self.parent[i]!=i:
            inter.add(i)
            i = self.parent[i]
        r = i
        for i in inter:
            self.parent[i] = r
        return r

    def connect(self, i, j):
        if i==j:
            return
        ri = self.root(i)
        rj = self.root(j)
        if ri==rj:
            return
        if self.size[ri]<self.size[rj]:
            self.parent[ri] = rj
            self.size[rj] += self.size[ri]
        else:
            self.parent[rj] = ri
            self.size[ri] += self.size[rj]
    
uf = UnionFindTree(n)
ns = [[] for _ in range(n)]
for i in range(m):
    a,b = [int(x)-1 for x in input().split()]
    uf.connect(a,b)
    ns[a].append(b)
    ns[b].append(a)

for i in range(k):
    c,d = [int(x)-1 for x in input().split()]
    ns[c].append(d)
    ns[d].append(c)
    
ans = [None]*n
for i in range(n):
    r = uf.root(i)
    s = uf.size[r]
    v = 0
    for j in ns[i]:
        if r==uf.root(j):
            v += 1
    ans[i] = s - v - 1
write(" ".join(map(str, ans)))
# Original solution
N,M,K=list(map(int, input().split()))
par=list(range(N))
nums=[0 for _ in range(N)]
rank=[0 for _ in range(N)]
#実装
def find(x):
    if par[x]==x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    if x==y:
        return
    if rank[x]<rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1
def same(x,y):
    return find(x)==find(y)

checked=[]

for _ in range(M):
  a1,a2=list(map(int, input().split()))
  a1-=1
  a2-=1
  if (min(a1,a2),max(a1,a2)) not in checked:
    checked.append((min(a1,a2),max(a1,a2)))
    unite(a1,a2)
    nums[a1]-=1
    nums[a2]-=1

for _ in range(K):
  a1,a2=list(map(int, input().split()))
  a1-=1
  a2-=1
  if same(a1,a2) and (min(a1,a2),max(a1,a2)) not in checked:
    nums[a1]-=1
    nums[a2]-=1
  if (min(a1,a2),max(a1,a2)) not in checked:
    checked.append((min(a1,a2),max(a1,a2)))
for i in range(N):
    par[i]=find(i)

for i in range(N):
    nums[i]=nums[i]+par.count(par[i])-1
print((" ".join(list(map(str,nums)))))

# Optimized solution
N,M,K=list(map(int, input().split()))
par=[-1 for _ in range(N)]
nums=[-1 for _ in range(N)]
#実装
def find(x):
    if par[x]<0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def size(x):
    return -par[find(x)]

def unite(x,y):
    x,y=find(x),find(y)
    if x==y:
        return
    if x>y:
        x,y=y,x
    par[x]+=par[y]
    par[y]=x

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


for _ in range(M):
    a1,a2=list(map(int, input().split()))
    a1-=1
    a2-=1
    unite(a1,a2)
    nums[a1]-=1
    nums[a2]-=1

for _ in range(K):
    a1,a2=list(map(int, input().split()))
    a1-=1
    a2-=1
    if same(a1,a2):
        nums[a1]-=1
        nums[a2]-=1


for i in range(N):
    nums[i]+=size(i)

print((" ".join(list(map(str,nums)))))
# Original solution
class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    """
    def find_root(self, x):
        root = self.root
        if root[x] == x:
            return x
        else:
            root[x] = self.find_root(root[x])
            return root[x]
    """
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy

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

uf = UnionFind(n)

ab = []
for _ in range(m):
    a, b = list(map(int, input().split()))
    ab.append((a, b))
    uf.merge(a-1, b-1)
cd = []
for _ in range(k):
    c, d = list(map(int, input().split()))
    cd.append((c, d))

#print(uf.root, uf.size)

ans = [uf.size[uf.find_root(uf.root[i])] - 1 for i in range(n)]

#print(' '.join(map(lambda x: str(x), ans)))
for a, b in ab:
    ans[a-1] -= 1
    ans[b-1] -= 1
#print(' '.join(map(lambda x: str(x), ans)))
for c, d in cd:
    if uf.find_root(uf.root[c-1]) == uf.find_root(uf.root[d-1]):
        ans[c-1] -= 1
        ans[d-1] -= 1
print((' '.join([str(x) for x in ans])))



# Optimized solution
class UnionFind:
    def __init__(self, n):
        self.root = list(range(n))
        self.size = [1] * (n)
    def find_root(self, x):
        root = self.root
        while root[x] != x:
            root[x] = root[root[x]]
            x = root[x]
        return x
    """
    def find_root(self, x):
        root = self.root
        if root[x] == x:
            return x
        else:
            root[x] = self.find_root(root[x])
            return root[x]
    """
    def merge(self, x, y):
        x = self.find_root(x)
        y = self.find_root(y)
        if x == y:
            return
        sx, sy = self.size[x], self.size[y]
        if sx < sy:
            self.root[x] = y
            self.size[y] += sx
        else:
            self.root[y] = x
            self.size[x] += sy

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

uf = UnionFind(n)

ab = []
for _ in range(m):
    a, b = list(map(int, input().split()))
    ab.append((a, b))
    uf.merge(a-1, b-1)
cd = []
for _ in range(k):
    c, d = list(map(int, input().split()))
    cd.append((c, d))

#print(uf.root, uf.size)

ans = [uf.size[uf.find_root(i)] - 1 for i in range(n)]

#print(' '.join(map(lambda x: str(x), ans)))
for a, b in ab:
    ans[a-1] -= 1
    ans[b-1] -= 1
#print(' '.join(map(lambda x: str(x), ans)))
for c, d in cd:
    #if uf.find_root(uf.root[c-1]) == uf.find_root(uf.root[d-1]):
    if uf.find_root(c-1) == uf.find_root(d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print((' '.join([str(x) for x in ans])))
# Original solution
# input
N, M, K = list(map(int, input().split()))

Frends = [[] for _ in range(N)]
Fs = [[] for _ in range(N)]
for _ in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    Frends[a].append(b)
    Frends[b].append(a)
    if a < b:
        Fs[a].append(b)
    else:
        Fs[b].append(a)

Blocked = [[] for _ in range(N)]
for _ in range(K):
    c, d = list(map(int, input().split()))
    c -= 1
    d -= 1
    Blocked[c].append(d)
    Blocked[d].append(c)

# process
# 友人グループを作成
fg = []
for i in range (N):
    l = Fs[i] 
    if len(l) == 0:
        continue

    l.append(i)
    s = set(l)

    t = -1
    j = 0
    fglen = len(fg)
    while j < fglen:
        sfg = s&fg[j]
        if len(sfg) > 0:
            if t < 0:
                t = j
                fg[j] |= s
            else:
                fg[t] |= fg[j]
                fg.pop(j)
                fglen -= 1
        j += 1

    if t < 0:
        fg.append(s)

# 友人候補を抽出、カウント
cand = [0 for _ in range(N)]
for g in fg:
    for f in g:
        cand[f] = len(g)-len(Frends[f])-len(set(Blocked[f])&g)-1

# output
#print(fg)
print((" ".join(map(str, cand))))


# Optimized solution
# input
N, M, K = list(map(int, input().split()))

Friends = [set() for _ in range(N)]
for _ in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    Friends[a].add(b)
    Friends[b].add(a)

Blocked = [set() for _ in range(N)]
for _ in range(K):
    c, d = list(map(int, input().split()))
    c -= 1
    d -= 1
    Blocked[c].add(d)
    Blocked[d].add(c)

# process
# 友人グループを作成
checked = set()
ans = [0]*N

for i in range (N):
    if i in checked:
        continue
    
    fg = set()

    stack = list(Friends[i])
    while stack:
        f = stack.pop()
        if f in checked:
            continue

        checked.add(f)
        fg.add(f)
        stack.extend(Friends[f])

    for f in fg:
        ans[f] += len(fg)-1-len(fg&(Friends[f]|Blocked[f]))

# output
print((" ".join(map(str, ans))))
# Original solution
from collections import defaultdict, deque
n, m, k = list(map(int, input().split()))
friends = defaultdict(list)
block = defaultdict(list)
for _ in range(m):
    a, b = list(map(int, input().split()))
    friends[a].append(b)
    friends[b].append(a)
for _ in range(k):
    c, d = list(map(int, input().split()))
    block[c].append(d)
    block[d].append(c)
#print(friends)
#print(block)

roopname = []
roop = defaultdict(list)
seen = [0]*n


for i in range(n):
    if not seen[i]==0:
        continue
    seen[i] = i+1
    roopname.append(i+1)
    roop[i+1].append(i+1)
    queue = deque(friends[i+1])
    while queue:
        p = queue.popleft()
        if  not seen[p-1]==0:continue
        seen[p-1] = i+1
        roop[i+1].append(p)
        for j in friends[p]:
            if seen[j-1]==0:
                queue.append(j)
#print(roopname)
#print(roop)
#print(seen)
ans = []
for i in range(n):
    fsum = 0
    for j in friends[i+1]:
        if j in roop[seen[i]]:
            fsum += 1
            
    bsum = 0
    for j in block[i+1]:
        if j in roop[seen[i]]:
            bsum += 1
    
    ans.append(len(roop[seen[i]])-bsum-fsum-1)

L=[str(a) for a in ans]
L=" ".join(L)
print(L)

# Optimized solution
from collections import defaultdict, deque
n, m, k = list(map(int, input().split()))
friends = defaultdict(set)
block = defaultdict(set)
for _ in range(m):
    a, b = list(map(int, input().split()))
    friends[a].add(b)
    friends[b].add(a)
for _ in range(k):
    c, d = list(map(int, input().split()))
    block[c].add(d)
    block[d].add(c)
#print(friends)
#print(block)

roopname = []
roop = defaultdict(set)
seen = [0]*n


for i in range(n):
    if not seen[i]==0:
        continue
    seen[i] = i+1
    roopname.append(i+1)
    roop[i+1].add(i+1)
    queue = deque(friends[i+1])
    while queue:
        p = queue.popleft()
        if  not seen[p-1]==0:continue
        seen[p-1] = i+1
        roop[i+1].add(p)
        for j in friends[p]:
            if seen[j-1]==0:
                queue.append(j)
#print(roopname)
#print(roop)
#print(seen)
ans = [len(roop[seen[i]])-len(roop[seen[i]]&friends[i+1])-len(roop[seen[i]]&block[i+1])-1 for i in range(n)]

    

L=[str(a) for a in ans]
L=" ".join(L)
print(L)
# Original solution
#n:
#m:
#k:
n,m,k=list(map(int,input().split()))
friend={}
block={}
result=[]
for i in range(1,n+1):
    friend[i]=set([])
    block[i]=set([])
    result.append(0)

for _ in range(m):
    a,b=list(map(int,input().split()))
    friend[a].add(b)
    friend[b].add(a)

for _ in range(k):
    a,b=list(map(int,input().split()))
    block[a].add(b)
    block[b].add(a)


checked=set([])
bfbf=[]
for i in range(1,n+1):
    #print(i,checked)
    if i not in checked:
        checked.add(i)
        group=set([i])
        bf=set([i])
        while len(group)!= 0:
            temp=group.pop()
            for item in friend[temp]:
                if item not in checked:
                    checked.add(item)
                    group.add(item)
                    bf.add(item)
        lenbf=len(bf)
        for item1 in bf:
            bl=0
            for item2 in bf:
                if item2 in block[item1]:
                    bl+=1
            result[item1-1]=lenbf-1-len(list(friend[item1]))-bl



        bfbf.append(bf)
result=list(map(str,result))
print((" ".join(result)))







# Optimized solution
#n:
#m:
#k:
n,m,k=list(map(int,input().split()))
friend={}
block={}
result=[]
friendGroup=[]
for i in range(1,n+1):
    friend[i]=set([])
    block[i]=set([])
    result.append(0)
    friendGroup.append(0)

for _ in range(m):
    a,b=list(map(int,input().split()))
    friend[a].add(b)
    friend[b].add(a)

checked=set([])
bfbf=[]
for i in range(1,n+1):
    #print(i,checked)
    if i not in checked:
        checked.add(i)
        group=set([i])
        bf=set([i])
        friendGroup[i-1]=i
        while len(group)!= 0:
            temp=group.pop()
            for item in friend[temp]:
                if item not in checked:
                    checked.add(item)
                    group.add(item)
                    bf.add(item)
                    friendGroup[item-1]=i
        lenbf=len(bf)
        for item1 in bf:
            result[item1-1]=lenbf-1-len(list(friend[item1]))

for _ in range(k):
    a,b=list(map(int,input().split()))
    if friendGroup[a-1]!=0 and friendGroup[a-1]==friendGroup[b-1]:
        result[a-1]-=1
        result[b-1]-=1

result=list(map(str,result))
print((" ".join(result)))
# Original solution
#n:
#m:
#k:
n,m,k=list(map(int,input().split()))
friend={}
block={}
result=[]
friendGroup=[]
for i in range(1,n+1):
    friend[i]=set([])
    block[i]=set([])
    result.append(0)
    friendGroup.append(0)

for _ in range(m):
    a,b=list(map(int,input().split()))
    friend[a].add(b)
    friend[b].add(a)

checked=set([])
bfbf=[]
for i in range(1,n+1):
    #print(i,checked)
    if i not in checked:
        checked.add(i)
        group=set([i])
        bf=set([i])
        friendGroup[i-1]=i
        while len(group)!= 0:
            temp=group.pop()
            for item in friend[temp]:
                if item not in checked:
                    checked.add(item)
                    group.add(item)
                    bf.add(item)
                    friendGroup[item-1]=i
        lenbf=len(bf)
        for item1 in bf:
            result[item1-1]=lenbf-1-len(list(friend[item1]))

for _ in range(k):
    a,b=list(map(int,input().split()))
    if friendGroup[a-1]!=0 and friendGroup[a-1]==friendGroup[b-1]:
        result[a-1]-=1
        result[b-1]-=1

result=list(map(str,result))
print((" ".join(result)))







# Optimized solution
#n:
#m:
#k:
n,m,k=list(map(int,input().split()))
friend={}
block={}

#resultは、ある人が何人の友達候補を持つかを保持する。
result=[]
#friendGroupは、ある人が何グループに所属するかを保持する。
friendGroup=[]

#初期化
for i in range(1,n+1):
    friend[i]=set([])
    block[i]=set([])
    result.append(0)
    friendGroup.append(0)

#友達関係を作る
for _ in range(m):
    a,b=list(map(int,input().split()))
    friend[a].add(b)
    friend[b].add(a)

#DFS
checked=set([])
bfbf=[]
for i in range(1,n+1):
    #print(i,checked)
    if i not in checked:
        checked.add(i)
        group=set([i])
        bf=set([i])
        friendGroup[i-1]=i
        while len(group)!= 0:
            temp=group.pop()
            for item in friend[temp]:
                if item not in checked:
                    checked.add(item)
                    group.add(item)
                    bf.add(item)
                    #誰がどのグループに所属するかを保持する
                    friendGroup[item-1]=i
        lenbf=len(bf)
        for item1 in bf:
            result[item1-1]=lenbf-1-len(list(friend[item1]))

#block関係を確認する
for _ in range(k):
    a,b=list(map(int,input().split()))

    #block関係にあるペアが、同じfirendGroupだったらマイナス１する
    if friendGroup[a-1]!=0 and friendGroup[a-1]==friendGroup[b-1]:
        result[a-1]-=1
        result[b-1]-=1

result=list(map(str,result))
print((" ".join(result)))