Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
n,m,k = map(int,input().split())
f = []
h = []
t = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(lambda x:int(x)-1,input().split())
  f.append((a,b))
  t[a].append(b)
  t[b].append(a)
for _ in range(k):
  a,b = map(lambda x:int(x)-1,input().split())
  h.append((a,b))
c = [False]*n

def dfs(d):
  c[d] = True
  ret=[]
  for i in t[d]:
    if not c[i]:
      ret += dfs(i)
  return [d] + ret

ans = [[] for _ in range(n)]
for i in range(n):
  if not c[i]:
    e = dfs(i)
    for j in e:
      ans[j] = list(e)
      ans[j].remove(j)
for i,j in f:
  ans[i].remove(j)
  ans[j].remove(i)
for i,j in h:
  if j in ans[i]:
    ans[i].remove(j)
  if i in ans[j]:
    ans[j].remove(i)
print(*map(len,ans))

Fixed submission:
n,m,k = map(int,input().split())
root = [i for i in range(n)]
height = [1 for i in range(n)]
def find(n):
  sn = n
  while n != root[n]:
    n = root[n]
  root[sn] = n
  return n
def union(a,b):
  a = find(a)
  b = find(b)
  if a==b:
    return
  elif height[a]>=height[b]:
    height[a] += height[b]
    height[b] = 0
    root[b] = a
  else:
    height[b] += height[a]
    height[a] = 0
    root[a] = b
l = [set() for _ in range(n)]
for i in range(m):
  a,b = map(lambda x:int(x)-1,input().split())
  union(a,b)
  l[a].add(b)
  l[b].add(a)
for i in range(k):
  a,b = map(lambda x:int(x)-1,input().split())
  if find(a)==find(b):
    l[a].add(b)
    l[b].add(a)
print(*[height[find(i)]-len(l[i])-1 for i in range(n)])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
n,m,k = map(int,input().split())
f = []
h = []
t = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(lambda x:int(x)-1,input().split())
  f.append((a,b))
  t[a].append(b)
  t[b].append(a)
for _ in range(k):
  a,b = map(lambda x:int(x)-1,input().split())
  h.append((a,b))
ans = [0]*n
c = [False]*n

def dfs(d):
  c[d] = True
  ret=[]
  for i in t[d]:
    if not c[i]:
      ret += dfs(i)
  return [d] + ret
m = []
for i in range(n):
  if not c[i]:
    e = dfs(i)
    g = len(e)-1
    if g > 1:
      m.append(set(e))
    for j in e:
      ans[j] = g
for i,j in f:
  ans[i]-=1
  ans[j]-=1
for i,j in h:
  for k in m:
    o = len(k & set((i,j)))
    if o == 2:
      ans[i]-=1
      ans[j]-=1
      break
    elif o == 1:
      break
print(*ans)

Fixed submission:
n,m,k = map(int,input().split())
root = [i for i in range(n)]
height = [1 for i in range(n)]
def find(n):
  sn = n
  while n != root[n]:
    n = root[n]
  root[sn] = n
  return n
def union(a,b):
  a = find(a)
  b = find(b)
  if a==b:
    return
  elif height[a]>=height[b]:
    height[a] += height[b]
    height[b] = 0
    root[b] = a
  else:
    height[b] += height[a]
    height[a] = 0
    root[a] = b
l = [set() for _ in range(n)]
for i in range(m):
  a,b = map(lambda x:int(x)-1,input().split())
  union(a,b)
  l[a].add(b)
  l[b].add(a)
for i in range(k):
  a,b = map(lambda x:int(x)-1,input().split())
  if find(a)==find(b):
    l[a].add(b)
    l[b].add(a)
print(*[height[find(i)]-len(l[i])-1 for i in range(n)])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
n,m,k = map(int,input().split())
f = []
h = []
t = [[] for _ in range(n)]
for _ in range(m):
  a,b = map(lambda x:int(x)-1,input().split())
  f.append((a,b))
  t[a].append(b)
  t[b].append(a)
for _ in range(k):
  a,b = map(lambda x:int(x)-1,input().split())
  h.append((a,b))
ans = [0]*n
c = [False]*n

def dfs(d):
  c[d] = True
  ret=[]
  for i in t[d]:
    if not c[i]:
      ret += dfs(i)
  return [d] + ret
m = []
for i in range(n):
  if not c[i]:
    e = dfs(i)
    m.append(set(e))
    g = len(e)-1
    for j in e:
      ans[j] = g
for i,j in f:
  ans[i]-=1
  ans[j]-=1
for i,j in h:
  for k in m:
    o = len(k & set((i,j)))
    if o == 2:
      ans[i]-=1
      ans[j]-=1
      break
    elif o == 1:
      break
print(*ans)

Fixed submission:
n,m,k = map(int,input().split())
root = [i for i in range(n)]
height = [1 for i in range(n)]
def find(n):
  sn = n
  while n != root[n]:
    n = root[n]
  root[sn] = n
  return n
def union(a,b):
  a = find(a)
  b = find(b)
  if a==b:
    return
  elif height[a]>=height[b]:
    height[a] += height[b]
    height[b] = 0
    root[b] = a
  else:
    height[b] += height[a]
    height[a] = 0
    root[a] = b
l = [set() for _ in range(n)]
for i in range(m):
  a,b = map(lambda x:int(x)-1,input().split())
  union(a,b)
  l[a].add(b)
  l[b].add(a)
for i in range(k):
  a,b = map(lambda x:int(x)-1,input().split())
  if find(a)==find(b):
    l[a].add(b)
    l[b].add(a)
print(*[height[find(i)]-len(l[i])-1 for i in range(n)])