Problem: An SNS has N users - User 1, User 2, \cdots, User N.  Between these N users, there are some relationships - M _friendships_ and K _blockships_.  For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i.  For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User C_i and User D_i.  We define User a to be a _friend candidate_ for User b when all of the following four conditions are satisfied:    * a \neq b.   * There is not a friendship between User a and User b.   * There is not a blockship between User a and User b.   * There exists a sequence c_0, c_1, c_2, \cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \cdots, L - 1.  For each user i = 1, 2, ... N, how many friend candidates does it have?

Submission attempts (in order):
nmk=input("").split(" ")
n=int(nmk[0])
m=int(nmk[1])
k=int(nmk[2])
listin=[-1]*n
listf=[]
listb=[]
for i in range(n):
    listf+=[[]]
    listb+=[[]]
for i in range(m):
    ab=input("").split(" ")
    a=int(ab[0])-1
    b=int(ab[1])-1
    listf[a]+=[b]
    listf[b]+=[a]
for i in range(k):
    ab=input("").split(" ")
    a=int(ab[0])-1
    b=int(ab[1])-1
    listb[a]+=[b]
    listb[b]+=[a]
s=-1
listff=[]

for i in range(n):
    if(listin[i]==-1):
        s+=1
        listin[i]=s
        listff+=[[i]]
        cnt=0
        
        while(len(listff[s])>cnt):
            for ii in listf[listff[s][cnt]]:
                if(listin[ii]==-1):
                    listin[ii]=s
                    listff[s]+=[ii]
                    
            cnt+=1
listans=[]

for i in range(n):
    
    listans+=[str(len(set(listff[listin[i]]))-1-len(listf[i]))]
print(" ".join(listans))

    



    
    


import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

import sys
sys.setrecursionlimit(10**9)
n,m,k=[int(i) for i in input().split()]
frends_num=[0 for i in range(n)]
def make_frends(m,n):
    data=[1 for i in range(m)]

    row=[]
    col=[]
    for k in range(m):
        i,j=[int(l) for l in input().split()]
        new_i=min(i,j)-1
        new_j=max(i,j)-1
        row.append(new_i)
        col.append(new_j)
        frends_num[new_i]+=1
        frends_num[new_j]+=1
    frend_sparce_matrix=csr_matrix((data, (row, col)),shape=(n,n))
    return frend_sparce_matrix


frends=make_frends(m,n)
l,labels=connected_components(frends)
labels
labels=list(labels)

class Group:
    def __init__(self,labels):
        self.labels=labels
        self.group_num=[0 for i in range(l)]
        for i in labels:
            self.group_num[i]+=1
    def get_group_num(self,i):
        return self.group_num[self.labels[i]]

group=Group(labels)


def get_frend_num(i):
    return frends_num[i]


def make_block(k,n):
    block_num=[0 for i in range(n)]
    for p in range(k):
        i,j =[int(l)-1 for l in input().split()]
        new_i=min(i,j)
        new_j=max(i,j)
        if labels[new_i]==labels[new_j]:
            block_num[i]+=1
            block_num[j]+=1
    return block_num

block=make_block(k,n)

def get_block_num(i):
    return block[i]

ans=[]
for i in range(n):
    ans.append(str(group.get_group_num(i)-1-get_frend_num(i)-get_block_num(i)))
print(" ".join(ans))


Verdicts: Wrong Answer

Accepted