Buggy python submission (verdict: Time Limit Exceeded):
def makeRelation():
  for n in range(1,N+1):
    visited=set((n,))
    D[n].add(n)
    while visited:
      v=visited.pop()
      for i in F[v]:
        if i not in D[n]:
          visited.add(i)
          D[n].add(i)
    for i in D[n]:
      D[i]|=D[n]


def main():
  makeRelation()
  #print(D)
  ans=[0]*(N+1)
  for n in range(1, N+1):
  	ans[n]=len(D[n]) - len(F[n]) - len(D[n]&B[n]) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[set() for n in range(N+1)]
  AB=[list(map(int, input().split())) for m in range(M)]
  for a,b in AB:
    F[a].add(b)
    F[b].add(a)
  B=[set() for n in range(N+1)]
  CD=[list(map(int, input().split())) for k in range(K)]
  for c,d in CD:
    B[c].add(d)
    B[d].add(c)
  D=[set() for n in range(N+1)]
  #print(F)
  #print(B)
  main()

Fixed submission:
def makeRelation():
  visited=[False]*(N+1)
  g=0 # group
  for n in range(1,N+1):
    if visited[n]:
      continue
    q={n}
    D.append(set())
    while q:
      j=q.pop()
      for i in F[j]: # search for friend
        if not visited[i]:
          visited[i]=True
          q.add(i)
          D[g]|={i}
    g+=1
    
def main():
  makeRelation()
  #print(D)
  for g in D:
    for d in g:
      ans[d]=len(g) - len(F[d]) - len(g&B[d]) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[set() for n in range(N+1)]
  AB=[list(map(int, input().split())) for m in range(M)]
  for a,b in AB:
    F[a].add(b)
    F[b].add(a)
  B=[set() for n in range(N+1)]
  CD=[list(map(int, input().split())) for k in range(K)]
  for c,d in CD:
    B[c].add(d)
    B[d].add(c)
  D=[]
  #print(F)
  #print(B)
  ans=[0]*(N+1)
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def makeRelation():
  for n in range(1,N+1):
    visited=set((n,))
    D[n].add(n)
    while visited:
      v=visited.pop()
      for i in F[v]:
        if i not in D[n]:
          visited.add(i)
          D[n].add(i)
          #D[i].add(n)


def main():
  makeRelation()
  #print(D)
  ans=[0]*(N+1)
  for n in range(1, N+1):
  	ans[n]=len(D[n]) - len(F[n]) - len(D[n]&set(B[n])) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[[] for n in range(N+1)]
  for m in range(M):
    a, b = map(int, input().split())
    F[a]+=[b]
    F[b]+=[a]
  B=[[] for n in range(N+1)]
  for k in range(K):
    c, d = map(int, input().split())
    B[c]+=[d]
    B[d]+=[c]
  D=[set() for n in range(N+1)]
  #print(F)
  #print(B)
  main()

Fixed submission:
def makeRelation():
  visited=[False]*(N+1)
  g=0 # group
  for n in range(1,N+1):
    if visited[n]:
      continue
    q={n}
    D.append(set())
    while q:
      j=q.pop()
      for i in F[j]: # search for friend
        if not visited[i]:
          visited[i]=True
          q.add(i)
          D[g]|={i}
    g+=1
    
def main():
  makeRelation()
  #print(D)
  for g in D:
    for d in g:
      ans[d]=len(g) - len(F[d]) - len(g&B[d]) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[set() for n in range(N+1)]
  AB=[list(map(int, input().split())) for m in range(M)]
  for a,b in AB:
    F[a].add(b)
    F[b].add(a)
  B=[set() for n in range(N+1)]
  CD=[list(map(int, input().split())) for k in range(K)]
  for c,d in CD:
    B[c].add(d)
    B[d].add(c)
  D=[]
  #print(F)
  #print(B)
  ans=[0]*(N+1)
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def makenetwork():
  for n in range(1,N+1):
    visited=set((n,))
    while visited:
      v=visited.pop()
      D[n].append(v)
      for i in F[v]:
        if i not in D[n]:
          visited.add(i)

        
def main():
  makenetwork()
  #print(D)
  ans=[0]*(N+1)
  for n in range(1, N+1):
  	ans[n]=len(D[n]) - len(F[n]) - len(set(D[n])&set(B[n])) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[[] for n in range(N+1)]
  for m in range(M):
    a, b = map(int, input().split())
    F[a]+=[b]
    F[b]+=[a]
  B=[[] for n in range(N+1)]
  for k in range(K):
    c, d = map(int, input().split())
    B[c]+=[d]
    B[d]+=[c]
  D=[[] for n in range(N+1)]
  #print(F)
  #print(B)
  main()

Fixed submission:
def makeRelation():
  visited=[False]*(N+1)
  g=0 # group
  for n in range(1,N+1):
    if visited[n]:
      continue
    q={n}
    D.append(set())
    while q:
      j=q.pop()
      for i in F[j]: # search for friend
        if not visited[i]:
          visited[i]=True
          q.add(i)
          D[g]|={i}
    g+=1
    
def main():
  makeRelation()
  #print(D)
  for g in D:
    for d in g:
      ans[d]=len(g) - len(F[d]) - len(g&B[d]) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[set() for n in range(N+1)]
  AB=[list(map(int, input().split())) for m in range(M)]
  for a,b in AB:
    F[a].add(b)
    F[b].add(a)
  B=[set() for n in range(N+1)]
  CD=[list(map(int, input().split())) for k in range(K)]
  for c,d in CD:
    B[c].add(d)
    B[d].add(c)
  D=[]
  #print(F)
  #print(B)
  ans=[0]*(N+1)
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(1000000)


def isFRIEND(a, b):
  return b in F[a] if a in F.keys() else False


def isBLOCK(c,d):
  return d in B[c] if c in B.keys() else False


def isFtoF(a, b, chk):
  #print(chk, a, b)
  chk.append(a)
  if a not in F.keys():
    return False
  for i in F[a]: # search for friends
    if not i in F.keys():
      continue
    if i in chk: # completed
      continue
    if i==b: # Friend to Friend
      return True
    else:
      if isFtoF(i, b, chk):
        return True
  return False


def calc():
  for n1 in range(1,N+1):
    for n2 in range(n1+1,N+1):
      #print(0,n1,n2,D)
      if not isBLOCK(n1,n2) and not isFRIEND(n1,n2) and isFtoF(n1,n2, []):
        D[n1]+=1
        D[n2]+=1


def main():
  calc()
  print(*D[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F={}
  for m in range(M):
    a, b = map(int, input().split())
    F[a]=F.get(a, []) + [b]
    F[b]=F.get(b, []) + [a]
  B={}
  for k in range(K):
    c, d = map(int, input().split())
    B[c]=B.get(c, []) + [d]
    B[d]=B.get(d, []) + [c]
  D=[0]*(N+1)
  #print(F)
  #print(B)
  main()

Fixed submission:
def makeRelation():
  visited=[False]*(N+1)
  g=0 # group
  for n in range(1,N+1):
    if visited[n]:
      continue
    q={n}
    D.append(set())
    while q:
      j=q.pop()
      for i in F[j]: # search for friend
        if not visited[i]:
          visited[i]=True
          q.add(i)
          D[g]|={i}
    g+=1
    
def main():
  makeRelation()
  #print(D)
  for g in D:
    for d in g:
      ans[d]=len(g) - len(F[d]) - len(g&B[d]) - 1
  print(*ans[1:])


if __name__=='__main__':
  N, M, K = map(int, input().split())
  F=[set() for n in range(N+1)]
  AB=[list(map(int, input().split())) for m in range(M)]
  for a,b in AB:
    F[a].add(b)
    F[b].add(a)
  B=[set() for n in range(N+1)]
  CD=[list(map(int, input().split())) for k in range(K)]
  for c,d in CD:
    B[c].add(d)
    B[d].add(c)
  D=[]
  #print(F)
  #print(B)
  ans=[0]*(N+1)
  main()