Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

for i in range(1,N+1):
    print(accompany[label[i]] + minus[i]-1)

time_all.append(time.time()-start)

#print(time_all)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Runtime Error):
f = open('C:/Users/naoki/Desktop/Atcoder/input.txt')

def make_list(length, loop):
    result = [[] for _ in range(length)]
    for _ in range(loop):
        a, b = map(lambda x: int(x) - 1, f.readline().split())
        result[a].append(b)
        result[b].append(a)
    return result

def main():
    # 敢えてDFSで解いてみる．
    n, m, k = map(int, f.readline().split())
    friend = make_list(n, m)
    brock = make_list(n, k)
    answer = [0] * n
    group_index = [0] * n
    group_id = 1

    def dfs(index):
        q = [index]
        group_index[index] = group_id
        connection = 1
        while not q == []:
            now = q.pop()
            for f in friend[now]:
                if group_index[f] == 0:
                    connection += 1
                    group_index[f] = group_id
                    q.append(f)
        return connection

    id_and_elements = {}
    for i in range(n):
        if group_index[i] == 0:
            id_and_elements[group_id] = dfs(i)
            group_id += 1

    for i in range(n):
        answer[i] += id_and_elements[group_index[i]] - 1
        answer[i] -= len(friend[i])
        for b in brock[i]:
            if group_index[b] == group_index[i]:
                answer[i] -= 1
    print(" ".join(map(str, answer)))


if __name__ == '__main__':
    main()



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
time_all.append(time.time()-start)

for k in range(N):
    if False not in seen:
        break
    num+=1
    H = seen.index(False)
    todo += [(H)]
    seen[H] = True
    group = []
    for j in range(N):
        if len(todo) <= 0:
            break
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            if seen[i] == False:
                todo += [i]
                seen[i] = True
    #print(group)
time_all.append(time.time()-start)
for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1


print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))
#for i in range(N):
#    print(accompany[label[i]] + minus[i]-1)
time_all.append(time.time()-start)

#print(time_all)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
    N ,M ,K = map(int,f.readline().split())
    A = [list(map(int,f.readline().split())) for _ in range(M)]
    C = [list(map(int,f.readline().split())) for _ in range(K)]

#N ,M ,K = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(M)]
#C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
time_all.append(time.time()-start)

for k in range(N):
    if False not in seen:
        break
    num+=1
    H = seen.index(False)
    todo += [(H)]
    seen[H] = True
    group = []
    for j in range(N):
        if len(todo) <= 0:
            break
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            if seen[i] == False:
                todo += [i]
                seen[i] = True
    #print(group)
time_all.append(time.time()-start)
for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1


print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))
#for i in range(N):
#    print(accompany[label[i]] + minus[i]-1)
time_all.append(time.time()-start)

#print(time_all)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
    
for k in range(N):
    if False not in seen:
        break
    num+=1
    H = seen.index(False)
    todo += [(H)]
    seen[H] = True
    group = []
    for j in range(N):
        if len(todo) <= 0:
            break
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            if seen[i] == False:
                todo += [i]
                seen[i] = True
    #print(group)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)
    


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = {i:False for i in range(N)}
#seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
    
while False in seen.values():
    num+=1
    #H = seen.index(False)
    H = [k for k,v in seen.items() if v == False][0]
    todo += [(H)]
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo += [i]
                seen[i] = True
    #print(group)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
    
while False in seen:
    num+=1
    H = seen.index(False)
    todo += [(H)]
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo += [i]
                seen[i] = True
    #print(group)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
    N ,M ,K = map(int,f.readline().split())
    A = [list(map(int,f.readline().split())) for _ in range(M)]
    C = [list(map(int,f.readline().split())) for _ in range(K)]

#N ,M ,K = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(M)]
#C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
    
while False in seen:
    num+=1
    H = seen.index(False)
    todo += [(H)]
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo += [i]
                seen[i] = True
    #print(group)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1].append(pair[1]-1)
    connection[pair[1]-1].append(pair[0]-1)
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
    
while False in seen:
    num+=1
    H = seen.index(False)
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo.append(i)
                seen[i] = True    
    #print(group)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1].append(pair[1]-1)
    connection[pair[1]-1].append(pair[0]-1)
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
    
while False in seen:
    num+=1
    H = seen.index(False)
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo.append(i)
                seen[i] = True    
    #print(group)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
    N ,M ,K = map(int,f.readline().split())
    A = [list(map(int,f.readline().split())) for _ in range(M)]
    C = [list(map(int,f.readline().split())) for _ in range(K)]

#N ,M ,K = map(int,input().split())
#A = [list(map(int,input().split())) for _ in range(M)]
#C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
#seen = {i:False for i in range(1,N+1)}
seen = [False]*N
#label = {i:0 for i in range(1,N+1)}
label = [0]*N
todo = deque()
num = 0
#minus = {i:0 for i in range(1,N+1)}
minus = [0]*N 
for pair in A:
    connection[pair[0]-1].append(pair[1]-1)
    connection[pair[1]-1].append(pair[0]-1)
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1
    
while False in seen:
    num+=1
    H = seen.index(False)
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo.append(i)
                seen[i] = True    
    #print(group)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1

for i in range(N):
    print(accompany[label[i]] + minus[i]-1)
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque

# =============================================================================
# with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#     N ,M ,K = map(int,f.readline().split())
#     A = [list(map(int,f.readline().split())) for _ in range(M)]
#     C = [list(map(int,f.readline().split())) for _ in range(K)]
# =============================================================================
def main():
    N ,M ,K = map(int,input().split())
    A = [list(map(int,input().split())) for _ in range(M)]
    C = [list(map(int,input().split())) for _ in range(K)]
    connection = {i:[] for i in range(1,N+1)}
    seen = {i:False for i in range(1,N+1)}
    label = {i:0 for i in range(1,N+1)}
    todo = deque()
    num = 0
    minus = {i:0 for i in range(1,N+1)}
    
    for pair in A:
        connection[pair[0]].append(pair[1])
        connection[pair[1]].append(pair[0])
        minus[pair[0]] -= 1
        minus[pair[1]] -= 1
        
    while False in seen.values():
        num+=1
        H = [k for k,v in seen.items() if v == False][0]
        todo.append(H)
        seen[H] = True
        group = set()
        while len(todo) > 0:
            current = todo.pop()
            label[current] = num
            group.add(current)
            for i in connection[current]:
                if seen[i] == False:
                    todo.append(i)
                    seen[i] = True
                    
        #print(group)
    
    for pair in C:
        if label[pair[0]] == label[pair[1]]:
            minus[pair[0]] -= 1
            minus[pair[1]] -= 1
    accompany = {i:0 for i in range(1,num+1)}
    for i in range(1,N+1):
        accompany[label[i]] += 1
    
    for i in range(1,N+1):
        print(accompany[label[i]] + minus[i]-1)
    
if __name__ == "__main__":
    main()
# =============================================================================
# A = {5:[5,4],4:[2,3]}
# A[5].append(6)
# del A[5][0]
# =============================================================================

# =============================================================================
#     block = 0
#     for block in C:
#         if block[0] in group and block in group:
#             cone_num -= 2
# =============================================================================
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import sys
# =============================================================================
# with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#     N ,M ,K = map(int,f.readline().split())
#     A = [list(map(int,f.readline().split())) for _ in range(M)]
#     C = [list(map(int,f.readline().split())) for _ in range(K)]
# =============================================================================
input = sys.stdin.readline
N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = {i:[] for i in range(1,N+1)}
seen = {i:False for i in range(1,N+1)}
label = {i:0 for i in range(1,N+1)}
todo = deque()
All = 0
num = 0
minus = {i:0 for i in range(1,N+1)}

for pair in A:
    connection[pair[0]].append(pair[1])
    connection[pair[1]].append(pair[0])
    minus[pair[0]] -= 1
    minus[pair[1]] -= 1
    
while False in seen.values():
    num+=1
    H = [k for k,v in seen.items() if v == False][0]
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo.append(i)
                seen[i] = True
                
    #print(group)

for pair in C:
    if label[pair[0]] == label[pair[1]]:
        minus[pair[0]] -= 1
        minus[pair[1]] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(1,N+1):
    accompany[label[i]] += 1

for i in range(1,N+1):
    print(accompany[label[i]] + minus[i]-1)
    

# =============================================================================
# A = {5:[5,4],4:[2,3]}
# A[5].append(6)
# del A[5][0]
# =============================================================================

# =============================================================================
#     block = 0
#     for block in C:
#         if block[0] in group and block in group:
#             cone_num -= 2
# =============================================================================
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import sys
# =============================================================================
# with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#     N ,M ,K = map(int,f.readline().split())
#     A = [list(map(int,f.readline().split())) for _ in range(M)]
#     C = [list(map(int,f.readline().split())) for _ in range(K)]
# =============================================================================
input = sys.stdin.readline
N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = {i:[] for i in range(1,N+1)}
seen = {i:False for i in range(1,N+1)}
label = {i:0 for i in range(1,N+1)}
todo = deque()
All = 0
num = 0

for pair in A:
    connection[pair[0]].append(pair[1])
    connection[pair[1]].append(pair[0])
    

while False in seen.values():
    num+=1
    H = [k for k,v in seen.items() if v == False][0]
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo.append(i)
                seen[i] = True
                
    #print(group)
minus = {i:0 for i in range(1,N+1)}
for pair in A:
    minus[pair[0]] -= 1
    minus[pair[1]] -= 1
for pair in C:
    if label[pair[0]] == label[pair[1]]:
        minus[pair[0]] -= 1
        minus[pair[1]] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(1,N+1):
    accompany[label[i]] += 1

for i in range(1,N+1):
    print(accompany[label[i]] + minus[i]-1)
    

# =============================================================================
# A = {5:[5,4],4:[2,3]}
# A[5].append(6)
# del A[5][0]
# =============================================================================

# =============================================================================
#     block = 0
#     for block in C:
#         if block[0] in group and block in group:
#             cone_num -= 2
# =============================================================================
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
# =============================================================================
# with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#     N ,M ,K = map(int,f.readline().split())
#     A = [list(map(int,f.readline().split())) for _ in range(M)]
#     C = [list(map(int,f.readline().split())) for _ in range(K)]
# =============================================================================

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = {i:[] for i in range(1,N+1)}
seen = {i:False for i in range(1,N+1)}
label = {i:0 for i in range(1,N+1)}
todo = deque()
All = 0
num = 0

for pair in A:
    connection[pair[0]].append(pair[1])
    connection[pair[1]].append(pair[0])
    

while False in seen.values():
    num+=1
    H = [k for k,v in seen.items() if v == False][0]
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo.append(i)
                seen[i] = True
                
    #print(group)
minus = {i:0 for i in range(1,N+1)}
for pair in A:
    minus[pair[0]] -= 1
    minus[pair[1]] -= 1
for pair in C:
    if label[pair[0]] == label[pair[1]]:
        minus[pair[0]] -= 1
        minus[pair[1]] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(1,N+1):
    accompany[label[i]] += 1

for i in range(1,N+1):
    print(accompany[label[i]] + minus[i]-1)
    

# =============================================================================
# A = {5:[5,4],4:[2,3]}
# A[5].append(6)
# del A[5][0]
# =============================================================================

# =============================================================================
#     block = 0
#     for block in C:
#         if block[0] in group and block in group:
#             cone_num -= 2
# =============================================================================
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
# =============================================================================
# with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#     N ,M ,K = map(int,f.readline().split())
#     A = [list(map(int,f.readline().split())) for _ in range(M)]
#     C = [list(map(int,f.readline().split())) for _ in range(K)]
# =============================================================================

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = {i:[] for i in range(1,N+1)}
seen = {i:False for i in range(1,N+1)}
label = {i:0 for i in range(1,N+1)}
todo = deque()
All = 0
num = 0

for pair in A:
    connection[pair[0]].append(pair[1])
    connection[pair[1]].append(pair[0])
    

while False in seen.values():
    num+=1
    H = [k for k,v in seen.items() if v == False][0]
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for i in connection[current]:
            if seen[i] == False:
                todo.append(i)
                seen[i] = True
                
    #print(group)
minus = {i:0 for i in range(1,N+1)}
for pair in A:
    minus[pair[0]] -= 1
    minus[pair[1]] -= 1
for pair in C:
    if label[pair[0]] == label[pair[1]]:
        minus[pair[0]] -= 1
        minus[pair[1]] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(1,N+1):
    accompany[label[i]] += 1

for i in range(1,N+1):
    print(accompany[label[i]] + minus[i]-1)
    

# =============================================================================
# A = {5:[5,4],4:[2,3]}
# A[5].append(6)
# del A[5][0]
# =============================================================================

# =============================================================================
#     block = 0
#     for block in C:
#         if block[0] in group and block in group:
#             cone_num -= 2
# =============================================================================
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
# =============================================================================
# with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#     N ,M ,K = map(int,f.readline().split())
#     A = [list(map(int,f.readline().split())) for _ in range(M)]
#     C = [list(map(int,f.readline().split())) for _ in range(K)]
# =============================================================================

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]

seen = {i:False for i in range(1,N+1)}
label = {i:0 for i in range(1,N+1)}
todo = deque()
All = 0
num = 0
while False in seen.values():
    num+=1
    H = [k for k,v in seen.items() if v == False][0]
    todo.append(H)
    seen[H] = True
    group = set()
    while len(todo) > 0:
        current = todo.pop()
        label[current] = num
        group.add(current)
        for connection in A:
            if connection[0] in group and connection[1] in group:
                continue
            elif connection[0] in group and seen[connection[1]] == False:
                todo.append(connection[1])
                seen[connection[1]] = True
            elif connection[1] in group and seen[connection[0]] == False:
                todo.append(connection[0])
                seen[connection[0]] = True

minus = {i:0 for i in range(1,N+1)}
for pair in A:
    minus[pair[0]] -= 1
    minus[pair[1]] -= 1
for pair in C:
    if label[pair[0]] == label[pair[1]]:
        minus[pair[0]] -= 1
        minus[pair[1]] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(1,N+1):
    accompany[label[i]] += 1

for i in range(1,N+1):
    print(accompany[label[i]] + minus[i]-1)
    

# =============================================================================
# A = {5:[5,4],4:[2,3]}
# A[5].append(6)
# del A[5][0]
# =============================================================================

# =============================================================================
#     block = 0
#     for block in C:
#         if block[0] in group and block in group:
#             cone_num -= 2
# =============================================================================
    

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Mon Mar  2 06:12:32 2020

@author: naoki
"""
from collections import deque
import time
start = time.time()
time_all = []
part_time1 = 0
part_time2 = 0
#with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#    N ,M ,K = map(int,f.readline().split())
#    A = [list(map(int,f.readline().split())) for _ in range(M)]
#    C = [list(map(int,f.readline().split())) for _ in range(K)]
    
time_all.append(time.time()-start)

N ,M ,K = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(M)]
C = [list(map(int,input().split())) for _ in range(K)]
connection = [[] for i in range(N)]
seen = [False]*N
label = [0]*N
todo = deque()
num = 0
minus = [0]*N

time_all.append(time.time()-start)
 
for pair in A:
    connection[pair[0]-1] += [(pair[1]-1)]
    connection[pair[1]-1] += [(pair[0]-1)]
    minus[pair[0]-1] -= 1
    minus[pair[1]-1] -= 1

time_all.append(time.time()-start)
count = 0
for k in range(N):
    time1 = time.time()
    num+=1
    if seen[k] == False:
        H = k
    else:
        continue
    todo += [(H)]
    seen[H] = True
    group = []
    part_time1 += time.time() - time1
    while not len(todo) == 0:
        current = todo.pop()
        label[current] = num
        group += [current]
        for i in connection[current]:
            count+=1
            if seen[i] == False:
                todo += [i]
                seen[i] = True
#print(count)
time_all.append(time.time()-start)

for pair in C:
    if label[pair[0]-1] == label[pair[1]-1]:
        minus[pair[0]-1] -= 1
        minus[pair[1]-1] -= 1
accompany = {i:0 for i in range(1,num+1)}
for i in range(N):
    accompany[label[i]] += 1
    
time_all.append(time.time()-start)

print(" ".join(map(lambda x,y : str(accompany[x]+y-1), label, minus)))

time_all.append(time.time()-start)

#print(time_all)