Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)
        self.friend = [[] for _ in range(n)]
        self.bad = [[] for _ in range(n)]
        
    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    

n, m, k = map(int, input().split())
U = UnionFind(n)

for _ in range(m):
    a, b = map(int, input().split())
    U.union(a - 1, b - 1)
    U.friend[a - 1].append(b - 1)
    U.friend[b - 1].append(a - 1)

for _ in range(k):
    c, d = map(int, input().split())
    U.bad[c - 1].append(d - 1)
    U.bad[d - 1].append(c - 1)

ans_list = []
for i in range(n):
    ans = len(U.friend[i]) * (-1)
    for j in range(n):
        if i != j:
            if U.same_check(i, j):
                if j not in U.bad[i]:
                    ans += 1 
    ans_list.append(str(ans))

print(' '.join(ans_list))

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.par = [-1]*n
        
    def find(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] = self.par[y] + self.par[x]
        self.par[y] = x

    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return self.par[self.find(x)]
    
    

n, m, k = map(int, input().split())
U = UnionFind(n)
fl = [0] * n
bl = [0] * n

for _ in range(m):
    a, b = map(int, input().split())
    U.union(a - 1, b - 1)
    fl[a - 1] += 1
    fl[b - 1] += 1

for _ in range(k):
    c, d = map(int, input().split())
    if U.same_check(c - 1, d - 1):
        bl[c - 1] += 1
        bl[d - 1] += 1

ans_list = []
for i in range(n):
    ans = -U.size(i) - fl[i] - bl[i] - 1
    ans_list.append(ans)
print(*ans_list)

Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)
        self.friend = [[] for _ in range(n)]
        self.bad = [[] for _ in range(n)]
        
    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    

n, m, k = map(int, input().split())
U = UnionFind(n)

for _ in range(m):
    a, b = map(int, input().split())
    U.union(a - 1, b - 1)
    U.friend[a - 1].append(b - 1)
    U.friend[b - 1].append(a - 1)

for _ in range(k):
    c, d = map(int, input().split())
    U.bad[c - 1].append(d - 1)
    U.bad[d - 1].append(c - 1)

ans_list = []
for i in range(n):
    ans = len(U.friend[i]) * (-1)
    for j in range(n):
        if i != j:
            if U.same_check(i, j):
                if j not in U.bad[i]:
                    ans += 1 
    ans_list.append(str(ans))

print(' '.join(ans_list))

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.par = [-1]*n
        
    def find(self, x):
        if self.par[x] < 0:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] = self.par[y] + self.par[x]
        self.par[y] = x

    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return self.par[self.find(x)]
    
    

n, m, k = map(int, input().split())
U = UnionFind(n)
fl = [0] * n
bl = [0] * n

for _ in range(m):
    a, b = map(int, input().split())
    U.union(a - 1, b - 1)
    fl[a - 1] += 1
    fl[b - 1] += 1

for _ in range(k):
    c, d = map(int, input().split())
    if U.same_check(c - 1, d - 1):
        bl[c - 1] += 1
        bl[d - 1] += 1

ans_list = []
for i in range(n):
    ans = -U.size(i) - fl[i] - bl[i] - 1
    ans_list.append(ans)
print(*ans_list)