Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
N,M,K = map(int,input().split())
fri = [[] for i in range(N+1)] #iさんの友達
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
bro = [[] for i in range(N+1)] #iさんのブロック
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

def dfs(i):
    seen[i] = True
    size_is[cur] += 1
    n_is[i] = cur
    for a in fri[i]:
        if not seen[a]: dfs(a)

seen = [False]*(N+1)
n_is = [0]*(N+1)
size_is = [0]
cur = 0
for i in range(1,N+1):
    if not seen[a]: #Falseで入る
        cur += 1
        size_is.append(0)
        dfs(i)

ans = [0]*N
for a in range(1,N+1):
    ans[a-1] = size_is[n_is[a]]-1
    for b in fri[a]:
        if n_is[b] == n_is[a]: ans[a-1] -= 1
    for d in bro[a]:
        if n_is[d] == n_is[a]: ans[a-1] -= 1

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

Fixed submission:
def find(x): #xの根を求める
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y): #xとyの属する集合の併合
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def same(x,y): #xとyが同じ集合に属するかの判定
    return find(x) == find(y)

def size(x): #xが属する集合の個数
    return -par[find(x)]

N,M,K = map(int, input().split())
par = [-1]*(N+1)
fri = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
    unite(a,b)

bro = [[] for i in range(N+1)]
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

ans = [0]*N
for i in range(1,N+1):
    ans[i-1] = size(i)-1
    for f in fri[i]:
        if same(f,i): ans[i-1] -= 1
    for b in bro[i]:
        if same(b,i): ans[i-1] -= 1

# print(par)
ans = list(map(str,ans))
print(" ".join(ans))

Buggy python submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
fri = [[] for i in range(N+1)] #iさんの友達
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
bro = [[] for i in range(N+1)] #iさんのブロック
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

def dfs(i):
    seen[i] = True
    size_is[cur] += 1
    n_is[i] = cur
    for a in fri[i]:
        if not seen[a]: dfs(a)

seen = [False]*(N+1)
n_is = [0]*(N+1)
size_is = [0]
cur = 0
for i in range(1,N+1):
    if not seen[a]: #Falseで入る
        cur += 1
        size_is.append(0)
        dfs(i)

ans = [0]*N
for a in range(1,N+1):
    ans[a-1] = size_is[n_is[a]]-1
    for b in fri[a]:
        if n_is[b] == n_is[a]: ans[a-1] -= 1
    for d in bro[a]:
        if n_is[d] == n_is[a]: ans[a-1] -= 1

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

Fixed submission:
def find(x): #xの根を求める
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y): #xとyの属する集合の併合
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def same(x,y): #xとyが同じ集合に属するかの判定
    return find(x) == find(y)

def size(x): #xが属する集合の個数
    return -par[find(x)]

N,M,K = map(int, input().split())
par = [-1]*(N+1)
fri = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    fri[a].append(b)
    fri[b].append(a)
    unite(a,b)

bro = [[] for i in range(N+1)]
for i in range(K):
    c,d = map(int,input().split())
    bro[c].append(d)
    bro[d].append(c)

ans = [0]*N
for i in range(1,N+1):
    ans[i-1] = size(i)-1
    for f in fri[i]:
        if same(f,i): ans[i-1] -= 1
    for b in bro[i]:
        if same(b,i): ans[i-1] -= 1

# print(par)
ans = list(map(str,ans))
print(" ".join(ans))