Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())

class UnionFind:
    def __init__(self,n):
        self.parent=[i for i in range(n)]
        self.rank=[0 for i in range(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):
            pass
        elif(self.rank[x] < self.rank[y]):
            self.parent[x] = y
        else:
            self.parent[y] = x
            if(self.rank[x] == self.rank[y]):
                self.rank[x]+=1

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

uf=UnionFind(n)
friendlist=[set() for _ in range(n)]
blocklist=[set() for _ in range(n)]


for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friendlist[a].add(b)
    friendlist[b].add(a)
    uf.unite(a,b)

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    blocklist[c].add(d)
    blocklist[d].add(c)

grouplist={}
rootlist=[]
for i in range(n):
    rooti=uf.find(i)
    rootlist.append(rooti)
    groupi=grouplist.get(rooti, set())
    groupi.add(i)
    grouplist[rooti]=groupi

ans=[]
for i in range(n):
    ans.append(len(grouplist[rootlist[i]] - friendlist[i] - blocklist[i] ) - 1)
print(*ans)


Fixed submission:
n,m,k=map(int,input().split())

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

    def find(self,x):
        if(self.group[x]==x):
            return x
        else:
            return self.find(self.group[x])

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            pass
        elif(self.sizeof(y) > self.sizeof(x)):
            self.group[x] = self.group[y]
            self.size[y] += self.size[x]
            self.size[x]=0
        else:
            self.group[y] = self.group[x]
            self.size[x] += self.size[y]
            self.size[y]=0

    def sizeof(self,a):
        return self.size[self.find(a)]

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

uf=UnionFind(n)
friends=[0 for _ in range(n)]
blocks=[0 for _ in range(n)]


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

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if(uf.same(c, d)):
        blocks[c]+=1
        blocks[d]+=1

ans=[]
for i in range(n):
    ans.append(uf.sizeof(i) - friends[i] - blocks[i]  - 1)
print(*ans)

Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())

#[index,parent]
unionfind=[[i,-1] for i in range(n)]
friendlist=[set() for _ in range(n)]
blocklist=[set() for _ in range(n)]

def findroot(ind):
    if(unionfind[ind][1]==-1):
        return unionfind[ind][0]
    else:
        return findroot(unionfind[ind][1])

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friendlist[a].add(b)
    friendlist[b].add(a)

    if(findroot(a) != findroot(b)):
        unionfind[findroot(b)][1]=unionfind[findroot(a)][0]

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    blocklist[c].add(d)
    blocklist[d].add(c)

grouplist={}
for i in range(n):
    rooti=findroot(i)
    groupi=grouplist.get(rooti, set())
    groupi.add(i)
    grouplist[rooti]=groupi

# print(unionfind)
# print(friendlist)
# print(blocklist)
# print(grouplist)

ans=[]
for i in range(n):
    ans.append(len(grouplist[findroot(i)] - friendlist[i] - blocklist[i] ) - 1)
print(*ans)


Fixed submission:
n,m,k=map(int,input().split())

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

    def find(self,x):
        if(self.group[x]==x):
            return x
        else:
            return self.find(self.group[x])

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            pass
        elif(self.sizeof(y) > self.sizeof(x)):
            self.group[x] = self.group[y]
            self.size[y] += self.size[x]
            self.size[x]=0
        else:
            self.group[y] = self.group[x]
            self.size[x] += self.size[y]
            self.size[y]=0

    def sizeof(self,a):
        return self.size[self.find(a)]

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

uf=UnionFind(n)
friends=[0 for _ in range(n)]
blocks=[0 for _ in range(n)]


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

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if(uf.same(c, d)):
        blocks[c]+=1
        blocks[d]+=1

ans=[]
for i in range(n):
    ans.append(uf.sizeof(i) - friends[i] - blocks[i]  - 1)
print(*ans)

Buggy python submission (verdict: Runtime Error):
import collections
n,m,k=map(int,input().split())

#[index,parent]
unionfind=[[i,-1] for i in range(n)]
friendlist=[[] for _ in range(n)]
blocklist=[[] for _ in range(n)]

def findroot(ind):
    if(unionfind[ind][1]==-1):
        return unionfind[ind][0]
    else:
        return findroot(unionfind[ind][1])

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friendlist[a].append(b)
    friendlist[b].append(a)

    if(findroot(a) != findroot(b)):
        unionfind[findroot(b)][1]=unionfind[findroot(a)][0]

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    blocklist[c].append(d)
    blocklist[d].append(c)

grouplist={}
for i in range(n):
    rooti=findroot(i)
    groupi=grouplist.get(rooti, [])
    groupi.append(i)
    grouplist[rooti]=groupi

ans=[]
for i in range(n):
    ans.append(len(set(grouplist[findroot(i)]) - set(friendlist[i]) - set(blocklist[i]) ) - 1)
print(*ans)


Fixed submission:
n,m,k=map(int,input().split())

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

    def find(self,x):
        if(self.group[x]==x):
            return x
        else:
            return self.find(self.group[x])

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            pass
        elif(self.sizeof(y) > self.sizeof(x)):
            self.group[x] = self.group[y]
            self.size[y] += self.size[x]
            self.size[x]=0
        else:
            self.group[y] = self.group[x]
            self.size[x] += self.size[y]
            self.size[y]=0

    def sizeof(self,a):
        return self.size[self.find(a)]

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

uf=UnionFind(n)
friends=[0 for _ in range(n)]
blocks=[0 for _ in range(n)]


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

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if(uf.same(c, d)):
        blocks[c]+=1
        blocks[d]+=1

ans=[]
for i in range(n):
    ans.append(uf.sizeof(i) - friends[i] - blocks[i]  - 1)
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import re
n,m,k=map(int,input().split())
friend=[set() for _ in range(n+1)]
block=[set([i]) for i in range(n+1)]
for _ in range(m):
    a,b=map(int,input().split())
    friend[a].add(b)
    friend[b].add(a)

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

ans=[]
friend_kouho=[friend[i] for i in range(n+1)]
#print(friend_kouho)
#print(block)
for i in range(1,n+1):
#    print("friend_kouho:"+str(friend_kouho))
    friend_assume=friend_kouho[i]
    temp=set()
    while(True):
        for j in list(friend_assume):
            temp = temp | friend[j]

#        print(i,temp,friend_assume,friend[i])

        if(len(temp)==0):
            ans.append(0)
            break
        elif(len(temp - friend_assume)>0):
            friend_assume = friend_assume | temp
        elif(len(temp - friend_assume)==0):
            friend_kouho[i] = friend_assume - block[i] - friend[i]
            ans.append(len(friend_kouho[i]))
            break
print(re.sub('[\[\],]','',str(ans)))

Fixed submission:
n,m,k=map(int,input().split())

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

    def find(self,x):
        if(self.group[x]==x):
            return x
        else:
            return self.find(self.group[x])

    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if(x==y):
            pass
        elif(self.sizeof(y) > self.sizeof(x)):
            self.group[x] = self.group[y]
            self.size[y] += self.size[x]
            self.size[x]=0
        else:
            self.group[y] = self.group[x]
            self.size[x] += self.size[y]
            self.size[y]=0

    def sizeof(self,a):
        return self.size[self.find(a)]

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

uf=UnionFind(n)
friends=[0 for _ in range(n)]
blocks=[0 for _ in range(n)]


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

for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if(uf.same(c, d)):
        blocks[c]+=1
        blocks[d]+=1

ans=[]
for i in range(n):
    ans.append(uf.sizeof(i) - friends[i] - blocks[i]  - 1)
print(*ans)