Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 9)

def dfs(x, seen):
  seen.add(x)
  for i in G[x]:
    if i in seen:
      continue
    dfs(i, seen)

N, M, K = map(int, input().split())

S = set()
G = [[] for i in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  G[A].append(B)
  G[B].append(A)
  S.add(A)
  S.add(B)

R = []
while len(S) != 0:
    seen = set()
    dfs(S.pop(), seen)
    R.append(seen)
    S = S - seen

Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add(D-1)
  Block[D-1].add(C-1)

seq = [0]*N

for r in R:
    lr = len(r)
    for j in r:
        seq[j] =  lr - len(G[j]) - len(r&Block[j]) - 1

print(*seq)


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

N, M, K = map(int, input().split())

Friend = [[] for i in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  Friend[A-1].append(B-1)
  Friend[B-1].append(A-1)

Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add(D-1)
  Block[D-1].add(C-1)


def dfs(x):
    if seen[x] == 0:
        R[cnt].add(x)
        seen[x]=1
        for i in Friend[x]:
            dfs(i)

seen = [0]*N
cnt  = 0
R    = []
for i in range(N):
    if seen[i] == 0:
        R.append(set())
        dfs(i)
        cnt += 1

seq = [0]*N

for r in R:
    lr = len(r)
    for j in r:
        seq[j] = lr - len(Friend[j]) - len(r&Block[j]) - 1

print(*seq)

Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 7)
# 深さ優先探索
def dfs(x, seen):
  seen.add(x)
  for i in G[x]:
    if i in seen:
      continue
    dfs(i, seen)

N, M, K = map(int, input().split())

# Graph構造を作らないといけない。
S = set()

G = [[] for i in range(N)]
#G = defaultdict(list)
for _ in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)
  S |= set([A-1, B-1])

#print(len(S))

#n_iter = 0
#R = defaultdict(set)
R = []
while len(S) != 0:
    seen = set()
    dfs(S.pop(), seen)
    #R[n_iter] = seen
    R.append(seen)
    S = S - seen
    #n_iter += 1

#print(R[0])

#Block = defaultdict(set)
Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add([D-1])
  Block[D-1].add([C-1])

seq = [0]*N

for r in R:
    for j in r:
        seq[j] = len(r) - len(G[j]) - len(r&Block[j]) - 1
#友達の距離はそのまま徐算して良い。
#ブロックリストは候補じゃないパターンが存在するので難しい。
print(*seq)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

N, M, K = map(int, input().split())

Friend = [[] for i in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  Friend[A-1].append(B-1)
  Friend[B-1].append(A-1)

Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add(D-1)
  Block[D-1].add(C-1)


def dfs(x):
    if seen[x] == 0:
        R[cnt].add(x)
        seen[x]=1
        for i in Friend[x]:
            dfs(i)

seen = [0]*N
cnt  = 0
R    = []
for i in range(N):
    if seen[i] == 0:
        R.append(set())
        dfs(i)
        cnt += 1

seq = [0]*N

for r in R:
    lr = len(r)
    for j in r:
        seq[j] = lr - len(Friend[j]) - len(r&Block[j]) - 1

print(*seq)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)
# 深さ優先探索
def dfs(x, seen):
  seen.add(x)
  for i in G[x]:
    if i in seen:
      continue
    dfs(i, seen)

N, M, K = map(int, input().split())

# Graph構造を作らないといけない。
S = set()
G = defaultdict(list)
for _ in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)
  S |= set([A-1, B-1])

n_iter = 0
R = defaultdict(set)
while len(S) != 0:
    seen = set()
    dfs(S.pop(), seen)
    R[n_iter] = seen
    S = S - seen
    n_iter += 1

Block = defaultdict(set)
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1] |= set([D-1])
  Block[D-1] |= set([C-1])

seq = [0]*N

for i in range(n_iter):
    r = R[i]
    for j in r:
        seq[j] = len(r) - len(G[j]) - len(r&Block[j]) - 1

print(*seq)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

N, M, K = map(int, input().split())

Friend = [[] for i in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  Friend[A-1].append(B-1)
  Friend[B-1].append(A-1)

Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add(D-1)
  Block[D-1].add(C-1)


def dfs(x):
    if seen[x] == 0:
        R[cnt].add(x)
        seen[x]=1
        for i in Friend[x]:
            dfs(i)

seen = [0]*N
cnt  = 0
R    = []
for i in range(N):
    if seen[i] == 0:
        R.append(set())
        dfs(i)
        cnt += 1

seq = [0]*N

for r in R:
    lr = len(r)
    for j in r:
        seq[j] = lr - len(Friend[j]) - len(r&Block[j]) - 1

print(*seq)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
# 深さ優先探索
def dfs(x, seen):
  seen.add(x)
  for i in G[x]:
    if i in seen:
      continue
    dfs(i, seen)

N, M, K = map(int, input().split())

# Graph構造を作らないといけない。
G = defaultdict(list)
for _ in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)
#print(G)

R = defaultdict(set)
for i in range(N):
  seen = set()
  dfs(i, seen)
  # 友達候補リストの作成
  R[i] = seen - set(G[i]) - set([i])
  #探索の都合で自分自身も入る。
  #すでに友達の要素は除外する。
#print(R)

#ブロックリストの反映
for _ in range(K):
  C, D = map(int, input().split())
  R[C-1].discard(D-1)
  R[D-1].discard(C-1)

#要素数が友達候補になる。
s = ''
for i in range(N):
  s += '{} '.format(len(R[i]))
print(s[:-1])

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

N, M, K = map(int, input().split())

Friend = [[] for i in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  Friend[A-1].append(B-1)
  Friend[B-1].append(A-1)

Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add(D-1)
  Block[D-1].add(C-1)


def dfs(x):
    if seen[x] == 0:
        R[cnt].add(x)
        seen[x]=1
        for i in Friend[x]:
            dfs(i)

seen = [0]*N
cnt  = 0
R    = []
for i in range(N):
    if seen[i] == 0:
        R.append(set())
        dfs(i)
        cnt += 1

seq = [0]*N

for r in R:
    lr = len(r)
    for j in r:
        seq[j] = lr - len(Friend[j]) - len(r&Block[j]) - 1

print(*seq)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
# 深さ優先探索
def dfs(x, seen):
  seen.add(x)
  for i in G[x]:
    if i in seen:
      continue
    dfs(i, seen)

N, M, K = map(int, input().split())

# Graph構造を作らないといけない。
G = defaultdict(list)
for _ in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)
#print(G)

R = defaultdict(set)
for i in range(N):
  seen = set()
  dfs(i, seen)
  # 友達候補リストの作成
  R[i] = seen - set(G[i]) - set([i])
  #探索の都合で自分自身も入る。
  #すでに友達の要素は除外する。
#print(R)

#ブロックリストの反映
for _ in range(K):
  C, D = map(int, input().split())
  R[C-1].discard(D-1)
  R[D-1].discard(C-1)

#要素数が友達候補になる。
s = ''
for i in range(N):
  s += f'{len(R[i])} '
print(s[:-1])




Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

N, M, K = map(int, input().split())

Friend = [[] for i in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  Friend[A-1].append(B-1)
  Friend[B-1].append(A-1)

Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add(D-1)
  Block[D-1].add(C-1)


def dfs(x):
    if seen[x] == 0:
        R[cnt].add(x)
        seen[x]=1
        for i in Friend[x]:
            dfs(i)

seen = [0]*N
cnt  = 0
R    = []
for i in range(N):
    if seen[i] == 0:
        R.append(set())
        dfs(i)
        cnt += 1

seq = [0]*N

for r in R:
    lr = len(r)
    for j in r:
        seq[j] = lr - len(Friend[j]) - len(r&Block[j]) - 1

print(*seq)