Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())

class UnionFind():
    def __init__( self, n ):
        self.n = n
        self.parents = [ - 1 ] * n
        
    def find( self, x ):
        if self.parents[ x ] < 0:
            return x
        else:
            self.parents[ x ] = self.find( self.parents[ x ] )
            return self.parents[ x ]

    def union( self, x, y ):
        x = self.find( x )
        y = self.find( y )
        if x == y:
            return
        if self.parents[ x ] > self.parents[ y ]:
            x, y = y, x
        self.parents[ x ] += self.parents[ y ]
        self.parents[ y ] = x
        
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

uf = UnionFind( N + 1 )
friends = [ [] for _ in range( N + 1 ) ]
for i in range( M ):
  a, b = map( int, input().split() )
  uf.union( a, b )
  friends[ a ].append( b )
  friends[ b ].append( a )

block = [ [] for _ in range( N + 1 ) ]
for i in range( K ):
  c, d = map( int, input().split() )
  block[ c ].append( d )
  block[ d ].append( c )

ans = str( len( set( uf.members( 1 )) - set( block[ 1 ] + friends[ 1 ]))  - 1 )
for i in range( 2, N + 1 ):
  ans += " " + str( len( set( uf.members( i )) - set( block[ i ] + friends[ i ]))  - 1 )
print( ans )

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

class UnionFind():
    def __init__( self, n ):
        self.n = n
        self.parents = [ - 1 ] * n
        
    def find( self, x ):
        if self.parents[ x ] < 0:
            return x
        else:
            self.parents[ x ] = self.find( self.parents[ x ] )
            return self.parents[ x ]

    def union( self, x, y ):
        x = self.find( x )
        y = self.find( y )
        if x == y:
            return
        if self.parents[ x ] > self.parents[ y ]:
            x, y = y, x
        self.parents[ x ] += self.parents[ y ]
        self.parents[ y ] = x
        
    def size( self, x ):
      return -self.parents[ self.find( x ) ]
        
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def same( self, x, y ):
      return self.find( x ) == self.find( y )

uf = UnionFind( N + 1 )
not_use = [ 0 ] * ( N + 1 )
for i in range( M ):
  a, b = map( int, input().split() )
  uf.union( a, b )
  not_use[ a ] += 1
  not_use[ b ] += 1

block = [ [] for _ in range( N + 1 ) ]
for i in range( K ):
  c, d = map( int, input().split() )
  if uf.same( c, d ):
    not_use[ c ] += 1
    not_use[ d ] += 1

ans = str( uf.size( 1 ) - not_use[ 1 ] - 1 )
for i in range( 2, N + 1 ):
  ans += " " + str( uf.size( i ) - not_use[ i ] - 1 )
print( ans )

Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map( int, input().split() )
friends = [ set() for _ in range( N + 1 ) ]

for i in range( M ):
  a, b = map( int, input().split())
  friends[ a ].add( b )
  friends[ b ].add( a )

friends_chain = []

sets = set( range( 1, N + 1) )

while sets != set():
  i = sets.pop()
  lists = [ i ]
  chain = { i }
  while lists != []:
    j = lists.pop()
    lists += list( friends[ j ] - chain )
    chain |=  friends[ j ]
  friends_chain.append( chain )
  sets -= chain

block = [ set() for _ in range( N + 1 )]
for i in range( K ):
  c, d = map( int, input().split() )
  block[ c ].add( d )
  block[ d ].add( c )

ans=""
for i in range( 1, N + 1 ):
    for u in friends_chain:
        if i in u:
            ans += str( len( u - friends[i] - block[i] - { i } ))
            break
    if i != N:
      ans += " "
print( ans )
    

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

class UnionFind():
    def __init__( self, n ):
        self.n = n
        self.parents = [ - 1 ] * n
        
    def find( self, x ):
        if self.parents[ x ] < 0:
            return x
        else:
            self.parents[ x ] = self.find( self.parents[ x ] )
            return self.parents[ x ]

    def union( self, x, y ):
        x = self.find( x )
        y = self.find( y )
        if x == y:
            return
        if self.parents[ x ] > self.parents[ y ]:
            x, y = y, x
        self.parents[ x ] += self.parents[ y ]
        self.parents[ y ] = x
        
    def size( self, x ):
      return -self.parents[ self.find( x ) ]
        
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def same( self, x, y ):
      return self.find( x ) == self.find( y )

uf = UnionFind( N + 1 )
not_use = [ 0 ] * ( N + 1 )
for i in range( M ):
  a, b = map( int, input().split() )
  uf.union( a, b )
  not_use[ a ] += 1
  not_use[ b ] += 1

block = [ [] for _ in range( N + 1 ) ]
for i in range( K ):
  c, d = map( int, input().split() )
  if uf.same( c, d ):
    not_use[ c ] += 1
    not_use[ d ] += 1

ans = str( uf.size( 1 ) - not_use[ 1 ] - 1 )
for i in range( 2, N + 1 ):
  ans += " " + str( uf.size( i ) - not_use[ i ] - 1 )
print( ans )