Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=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=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=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))))

Fixed submission:
N,M,K=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=map(int, input().split())
    a1-=1
    a2-=1
    unite(a1,a2)
    nums[a1]-=1
    nums[a2]-=1

for _ in range(K):
    a1,a2=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))))

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int, input().split())
par=list(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)

eandb=[(i,i)for i in range(N)]
for _ in range(M):
  a1,a2=map(int, input().split())
  a1-=1
  a2-=1
  eandb.append((a1,a2))
  eandb.append((a2,a1))
  unite(a1,a2)
for _ in range(K):
  a1,a2=map(int, input().split())
  a1-=1
  a2-=1
  eandb.append((a1,a2))
  eandb.append((a2,a1))
ans=[]
for i in range(N):
  ans_i=len([ bb for bb in range(N) if same(bb,i) and (bb,i) not in eandb])
  ans.append(str(ans_i))
print(' '.join(ans))
  

Fixed submission:
N,M,K=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=map(int, input().split())
    a1-=1
    a2-=1
    unite(a1,a2)
    nums[a1]-=1
    nums[a2]-=1

for _ in range(K):
    a1,a2=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))))