Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import sys
input = sys.stdin.readline

def connected_components(graph):
  seen = set()
  def component(n):
    nodes = set([n])
    while nodes:
      n = nodes.pop()
      seen.add(n)
      nodes |= set(graph[n]) - seen
      yield n
  for n in graph:
    if n not in seen:
      yield component(n)

n,m,k=map(int,input().split())
friend={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  friend[a-1].add(b-1)
  friend[b-1].add(a-1)
block={i:set() for i in range(n)}
for i in range(k):
  c,d=map(int,input().split())
  block[c-1].add(d-1)
  block[d-1].add(c-1)
checked=set()
belongs=[-1 for i in range(n)]
renketsu=[]
b = 0
g = [list(x) for x in connected_components(friend)]
fnum=[-1 for i in range(n)]
for graph in g:
  s = set(graph)
  for x in graph:
    fnum[x] = len(s - friend[x] - block[x]) - 1
print(' '.join(map(str,fnum)))

Fixed submission:
import sys
input = sys.stdin.readline

def connected_components(graph):
  seen = set()
  def component(n):
    nodes = set([n])
    while nodes:
      n = nodes.pop()
      seen.add(n)
      nodes |= graph[n] - seen
      yield n
  for n in graph:
    if n not in seen:
      yield component(n)

n,m,k=map(int,input().split())
friend={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  friend[a-1].add(b-1)
  friend[b-1].add(a-1)
block={i:set() for i in range(n)}
for i in range(k):
  c,d=map(int,input().split())
  block[c-1].add(d-1)
  block[d-1].add(c-1)
c = connected_components(friend)
fnum=[-1 for i in range(n)]
for graph in c:
  s = set(graph)
  for x in s:
    fnum[x] = len(s) - len(s & block[x]) -len(friend[x])- 1
print(' '.join(map(str,fnum)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n,m,k=map(int,input().split())
friend={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  friend[a-1].add(b-1)
  friend[b-1].add(a-1)
block={i:set() for i in range(n)}
for i in range(k):
  c,d=map(int,input().split())
  block[c-1].add(d-1)
  block[d-1].add(c-1)
checked=set()
belongs=[-1 for i in range(n)]
renketsu=[]
b = 0
for i in range(n):
  if i in checked:
    continue
  g = set()
  queue = deque([i])
  while(queue):
    t = queue.popleft()
    if t in checked:
      continue
    checked.add(t)
    g.add(t)
    belongs[t] = b
    queue.extend(friend[t])
  renketsu.append(g)
  b += 1
fnum=[]
for i in range(n):
  fnum.append(len( renketsu[belongs[i]] - friend[i] - block[i])-1)
print(' '.join(map(str,fnum)))

Fixed submission:
import sys
input = sys.stdin.readline

def connected_components(graph):
  seen = set()
  def component(n):
    nodes = set([n])
    while nodes:
      n = nodes.pop()
      seen.add(n)
      nodes |= graph[n] - seen
      yield n
  for n in graph:
    if n not in seen:
      yield component(n)

n,m,k=map(int,input().split())
friend={i:set() for i in range(n)}
for i in range(m):
  a,b=map(int,input().split())
  friend[a-1].add(b-1)
  friend[b-1].add(a-1)
block={i:set() for i in range(n)}
for i in range(k):
  c,d=map(int,input().split())
  block[c-1].add(d-1)
  block[d-1].add(c-1)
c = connected_components(friend)
fnum=[-1 for i in range(n)]
for graph in c:
  s = set(graph)
  for x in s:
    fnum[x] = len(s) - len(s & block[x]) -len(friend[x])- 1
print(' '.join(map(str,fnum)))