Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = defaultdict(set)

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

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

def dfs(i):
    ret = set()
    unvisited = [i]

    while len(unvisited) > 0:
        v = unvisited.pop()
        ret.add(v)
        for w in fr[v]:
            if w in ret or w in unvisited:
                continue
            unvisited.append(w)
    return ret


for i in range(n):
  s = dfs(i)
  for j in bl[i]:
    if j in s:
      s.remove(j)
  print(len(s) - len(fr[i]) - 1, end=' ')
print()

Fixed submission:
from collections import defaultdict
import time
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = []
start = time.time()
group = [0] * n

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

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl.append((a,b))


g_num = 0
for i in range(n):
    if group[i] != 0:
        continue
    g_num += 1
    unvisited = set({i})
    while len(unvisited) > 0:
        v = unvisited.pop()
        group[v] = g_num
        for w in fr[v]:
            if group[w] > 0 or w in unvisited:
                continue
            unvisited.add(w)

group_size = defaultdict(int)
for x in group:
    group_size[x] += 1

bl_in_group = [0] * n
for a,b in bl:
    if group[a] == group[b]:
        bl_in_group[a] += 1
        bl_in_group[b] += 1

for i in range(n):
    print(group_size[group[i]] - len(fr[i]) - bl_in_group[i] - 1, end=' ')

print()

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

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

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

def dfs(i, g):
  g.add(i)
  for a in fr[i]:
    if a not in g:
      dfs(a, g)

for i in range(n):
  s = set()
  dfs(i, s)
  for j in bl[i]:
    if j in s:
      s.remove(j)
  print(len(s) - len(fr[i]) - 1, end=' ')
print()

Fixed submission:
from collections import defaultdict
import time
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = []
start = time.time()
group = [0] * n

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

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl.append((a,b))


g_num = 0
for i in range(n):
    if group[i] != 0:
        continue
    g_num += 1
    unvisited = set({i})
    while len(unvisited) > 0:
        v = unvisited.pop()
        group[v] = g_num
        for w in fr[v]:
            if group[w] > 0 or w in unvisited:
                continue
            unvisited.add(w)

group_size = defaultdict(int)
for x in group:
    group_size[x] += 1

bl_in_group = [0] * n
for a,b in bl:
    if group[a] == group[b]:
        bl_in_group[a] += 1
        bl_in_group[b] += 1

for i in range(n):
    print(group_size[group[i]] - len(fr[i]) - bl_in_group[i] - 1, end=' ')

print()