Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
group_id = {i:[] for i in range(1, N+1)}
group = {}
isChecked = [0] * (N + 1)

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
g = 0
for i in range(1, N+1):
    if isChecked[i]:
        continue
    isChecked[i] = 1
    isChecked[i] = 1
    group_id[i] = g
    x = [i]
    ch = child[i].copy()
    while ch:
        c = ch.pop(0)
        if isChecked[c]:
            continue
        group_id[c] = g
        isChecked[c] = 1
        x.append(c)
        ch = list(set(ch) | set(child[c]) - set(x))
    group[g] = len(x)
    g += 1

for i in range(1, N+1):
    ans[i] = group[group_id[i]] - len(child[i]) - 1

for _ in range(K):
    c, d = map(int, input().split())
    if group_id[c] == group_id[d]:
        ans[c] -= 1
        ans[d] -= 1
        
print(*ans[1:])

Fixed submission:
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
isChecked = [0] * (N + 1)
isBlocked = [set() for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
for _ in range(K):
    c, d = map(int, input().split())
    isBlocked[c].add(d)
    isBlocked[d].add(c)
    
for i in range(1, N+1):
    if isChecked[i]:
        continue
    isChecked[i] = 1
    x = set([i])
    ch = child[i].copy()
    while ch:
        c = ch.pop()
        if isChecked[c]:
            continue
        isChecked[c] = 1
        x.add(c)
        ch.extend(child[c])
    for j in x:
        ans[j] = len(x) - 1 - len(child[j]) - len(x & isBlocked[j])
        
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
group_id = {i:[] for i in range(1, N+1)}
group = {}
isChecked = [0] * (N + 1)

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
X = []
g = 0
i = 1
while len(X) != N:
    if isChecked[i]:
        i += 1
        continue
    isChecked[i] = 1
    group_id[i] = g
    x = [i]
    ch = child[i].copy()
    while ch:
        c = ch.pop(0)
        group_id[c] = g
        isChecked[c] = 1
        x.append(c)
        ch = list(set(ch) | set(child[c]) - set(x))        
    group[g] = len(x)
    X += x
    g += 1
    i += 1

for i in range(1, N+1):
    ans[i] = group[group_id[i]] - len(child[i]) - 1

for _ in range(K):
    c, d = map(int, input().split())
    if group_id[c] == group_id[d]:
        ans[c] -= 1
        ans[d] -= 1
        
print(*ans[1:])

Fixed submission:
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
isChecked = [0] * (N + 1)
isBlocked = [set() for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
for _ in range(K):
    c, d = map(int, input().split())
    isBlocked[c].add(d)
    isBlocked[d].add(c)
    
for i in range(1, N+1):
    if isChecked[i]:
        continue
    isChecked[i] = 1
    x = set([i])
    ch = child[i].copy()
    while ch:
        c = ch.pop()
        if isChecked[c]:
            continue
        isChecked[c] = 1
        x.add(c)
        ch.extend(child[c])
    for j in x:
        ans[j] = len(x) - 1 - len(child[j]) - len(x & isBlocked[j])
        
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
group_id = {i:[] for i in range(1, N+1)}
group = {}

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
X = set(range(1, N+1))
g = 0
while X:
    i = X.pop()
    group_id[i] = g
    x = {i}
    ch = set(child[i])
    while ch:
        c = ch.pop()
        group_id[c] = g
        ch = (ch | set(child[c])) - set(x)
        x = x | {c}
    group[g] = len(x)
    X = X - set(x)
    g += 1

for i in range(1, N+1):
    ans[i] = group[group_id[i]] - len(child[i]) - 1

for _ in range(K):
    c, d = map(int, input().split())
    if group_id[c] == group_id[d]:
        ans[c] -= 1
        ans[d] -= 1

print(*ans[1:])

Fixed submission:
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
isChecked = [0] * (N + 1)
isBlocked = [set() for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
for _ in range(K):
    c, d = map(int, input().split())
    isBlocked[c].add(d)
    isBlocked[d].add(c)
    
for i in range(1, N+1):
    if isChecked[i]:
        continue
    isChecked[i] = 1
    x = set([i])
    ch = child[i].copy()
    while ch:
        c = ch.pop()
        if isChecked[c]:
            continue
        isChecked[c] = 1
        x.add(c)
        ch.extend(child[c])
    for j in x:
        ans[j] = len(x) - 1 - len(child[j]) - len(x & isBlocked[j])
        
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
group_id = {i:[] for i in range(1, N+1)}
group = {}

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
X = set(range(1, N+1))
g = 0
while X:
    i = X.pop()
    group_id[i] = g
    x = {i}
    ch = set(child[i])
    while ch:
        c = ch.pop()
        group_id[c] = g
        ch = (ch | set(child[c])) - set(x)
        x = x | {c}
    group[g] = x
    X = X - set(x)
    g += 1

for i in range(1, N+1):
    ans[i] = len(group[group_id[i]]) - len(child[i]) - 1

for _ in range(K):
    c, d = map(int, input().split())
    if group_id[c] == group_id[d]:
        ans[c] -= 1
        ans[d] -= 1

print(*ans[1:])

Fixed submission:
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
isChecked = [0] * (N + 1)
isBlocked = [set() for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
for _ in range(K):
    c, d = map(int, input().split())
    isBlocked[c].add(d)
    isBlocked[d].add(c)
    
for i in range(1, N+1):
    if isChecked[i]:
        continue
    isChecked[i] = 1
    x = set([i])
    ch = child[i].copy()
    while ch:
        c = ch.pop()
        if isChecked[c]:
            continue
        isChecked[c] = 1
        x.add(c)
        ch.extend(child[c])
    for j in x:
        ans[j] = len(x) - 1 - len(child[j]) - len(x & isBlocked[j])
        
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np


N, M, K = map(int, input().split())
ans = np.zeros((N+1,), dtype=int)
child = {i:[] for i in range(1, N+1)}
isBlocked = {i:[] for i in range(1, N+1)}
group = np.zeros((N+1,))

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)

for i in range(1, N+1):
    ans[i] = ans[i] - len(child[i]) - 1 
    
X = set(range(1, N+1))
g = 0
while X:
    i = X.pop()
    x = {i}
    ch = set(child[i])
    while ch:
        c = ch.pop()
        ch = (ch | set(child[c])) - set(x)
        x = x | {c}
    ans[list(x)] += len(x)
    group[list(x)] = g
    X = X - set(x)
    g += 1
        
for _ in range(K):
    c, d = map(int, input().split())
    if group[c] == group[d]:
        ans[c] -= 1
        ans[d] -= 1

print(*ans[1:])

Fixed submission:
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
isChecked = [0] * (N + 1)
isBlocked = [set() for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
for _ in range(K):
    c, d = map(int, input().split())
    isBlocked[c].add(d)
    isBlocked[d].add(c)
    
for i in range(1, N+1):
    if isChecked[i]:
        continue
    isChecked[i] = 1
    x = set([i])
    ch = child[i].copy()
    while ch:
        c = ch.pop()
        if isChecked[c]:
            continue
        isChecked[c] = 1
        x.add(c)
        ch.extend(child[c])
    for j in x:
        ans[j] = len(x) - 1 - len(child[j]) - len(x & isBlocked[j])
        
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
ans = []
child = {i:[] for i in range(1, N+1)}
isBlocked = {i:[] for i in range(1, N+1)}

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)

for _ in range(K):
    c, d = map(int, input().split())
    isBlocked[c].append(d)
    isBlocked[d].append(c)
    
for i in range(1, N+1):
    x = [i]
    ch = set(child[i])
    while ch:
        c = ch.pop()
        ch = (ch | set(child[c])) - set(x)
        x.append(c)
    ans.append(len(set(x) - set(isBlocked[i])) - 1 - len(child[i]))
    
print(*ans)

Fixed submission:
N, M, K = map(int, input().split())
ans = [0] * (N + 1)
child = {i:[] for i in range(1, N+1)}
isChecked = [0] * (N + 1)
isBlocked = [set() for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    child[a].append(b)
    child[b].append(a)
    
for _ in range(K):
    c, d = map(int, input().split())
    isBlocked[c].add(d)
    isBlocked[d].add(c)
    
for i in range(1, N+1):
    if isChecked[i]:
        continue
    isChecked[i] = 1
    x = set([i])
    ch = child[i].copy()
    while ch:
        c = ch.pop()
        if isChecked[c]:
            continue
        isChecked[c] = 1
        x.add(c)
        ch.extend(child[c])
    for j in x:
        ans[j] = len(x) - 1 - len(child[j]) - len(x & isBlocked[j])
        
print(*ans[1:])