Buggy python submission (verdict: Time Limit Exceeded):
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [[] for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
ans = [0 for i in range(n)]
data = [0 for i in range(n)] #見たら1
for i in range(n): #自分がi
    if(data[i] != 0):
        break
    data[i] = 1
    data2 = ab[i] + [i]
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = []
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0):
                    data[frfr] = 1
                    new.append(frfr)
                    data2.append(frfr)
        if(len(new)==0):
            break
        else:
            new_friends.append(new)
    for j in data2:
        count = 0
        for ano in data2:
            if(j != ano and ano not in ab[j] and ano not in cd[j]):
                count += 1
        ans[j] = count


print(*ans)

Fixed submission:
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [set([]) for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].add(d-1)
    cd[d-1].add(c-1)
    
ans = [0 for i in range(n)]
data = [0 for i in range(n)] #見たら1
for i in range(n): #自分がi
    if(data[i] != 0): #もう見てたら必要なし
        continue
    data[i] = 1 #iの人を見る
    data2 = ab[i] + [i]
    data2 = set(data2)
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = [] #次の深さのリスト
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0): #見てなかったら加える
                    data[frfr] = 1 
                    new.append(frfr) #次の深さのリストに足す
                    data2.add(frfr) #グラフに足す
        if(len(new)==0):
            break
        else:
            new_friends.append(new)

    sam = len(data2)
    for j in data2:
        count = sam
        ans[j] = count - len(ab[j]) - len(cd[j] & data2) - 1 #自分と友達を除く


print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [[] for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
ans = []
for i in range(n): #自分がi
    data = [0 for i in range(n)] #友人は1
    count = 0
    data[i] = 2
    for j in ab[i]:
        data[j] = 1
    for j in cd[i]:
        data[j] = -1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = []
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0):
                    data[frfr] = 1
                    new.append(frfr)
                    count += 1
                elif(data[frfr] == -1):
                    new.append(frfr)
        if(len(new)==0):
            break
        else:
            new_friends.append(new)
    ans.append(count)

print(*ans)

Fixed submission:
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [set([]) for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].add(d-1)
    cd[d-1].add(c-1)
    
ans = [0 for i in range(n)]
data = [0 for i in range(n)] #見たら1
for i in range(n): #自分がi
    if(data[i] != 0): #もう見てたら必要なし
        continue
    data[i] = 1 #iの人を見る
    data2 = ab[i] + [i]
    data2 = set(data2)
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = [] #次の深さのリスト
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0): #見てなかったら加える
                    data[frfr] = 1 
                    new.append(frfr) #次の深さのリストに足す
                    data2.add(frfr) #グラフに足す
        if(len(new)==0):
            break
        else:
            new_friends.append(new)

    sam = len(data2)
    for j in data2:
        count = sam
        ans[j] = count - len(ab[j]) - len(cd[j] & data2) - 1 #自分と友達を除く


print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [[] for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
ans = [0 for i in range(n)]
for i in range(n): #自分がi
    if(ans[i] != 0):
        break
    data = [0 for i in range(n)] #友人は1
    data[i] = 2
    data2 = ab[i] + [i]
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = []
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0):
                    data[frfr] = 1
                    new.append(frfr)
                    data2.append(frfr)
        if(len(new)==0):
            break
        else:
            new_friends.append(new)
    for j in data2:
        count = 0
        for ano in data2:
            if(j != ano and ano not in ab[j] and ano not in cd[j]):
                count += 1
        ans[j] = count


print(*ans)

Fixed submission:
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [set([]) for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].add(d-1)
    cd[d-1].add(c-1)
    
ans = [0 for i in range(n)]
data = [0 for i in range(n)] #見たら1
for i in range(n): #自分がi
    if(data[i] != 0): #もう見てたら必要なし
        continue
    data[i] = 1 #iの人を見る
    data2 = ab[i] + [i]
    data2 = set(data2)
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = [] #次の深さのリスト
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0): #見てなかったら加える
                    data[frfr] = 1 
                    new.append(frfr) #次の深さのリストに足す
                    data2.add(frfr) #グラフに足す
        if(len(new)==0):
            break
        else:
            new_friends.append(new)

    sam = len(data2)
    for j in data2:
        count = sam
        ans[j] = count - len(ab[j]) - len(cd[j] & data2) - 1 #自分と友達を除く


print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [[] for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
ans = [0 for i in range(n)]
for i in range(n): #自分がi
    if(ans[i] != 0):
        break
    data = [0 for i in range(n)] #友人は1
    data[i] = 2
    data2 = ab[i] + [i]
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = []
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0):
                    data[frfr] = 1
                    new.append(frfr)
                    data2.append(frfr)
        if(len(new)==0):
            break
        else:
            new_friends.append(new)
    for j in data2:
        count = 0
        for ano in data2:
            if(j != ano and ano not in ab[j] and ano not in cd[j]):
                count += 1
        ans[j] = count


print(*ans)

Fixed submission:
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [set([]) for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].add(d-1)
    cd[d-1].add(c-1)
    
ans = [0 for i in range(n)]
data = [0 for i in range(n)] #見たら1
for i in range(n): #自分がi
    if(data[i] != 0): #もう見てたら必要なし
        continue
    data[i] = 1 #iの人を見る
    data2 = ab[i] + [i]
    data2 = set(data2)
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = [] #次の深さのリスト
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0): #見てなかったら加える
                    data[frfr] = 1 
                    new.append(frfr) #次の深さのリストに足す
                    data2.add(frfr) #グラフに足す
        if(len(new)==0):
            break
        else:
            new_friends.append(new)

    sam = len(data2)
    for j in data2:
        count = sam
        ans[j] = count - len(ab[j]) - len(cd[j] & data2) - 1 #自分と友達を除く


print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [[] for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].append(d-1)
    cd[d-1].append(c-1)
    
ans = []
for i in range(n): #自分がi
    data = [0 for i in range(n)] #友人は1
    count = 0
    data[i] = 2
    for j in ab[i]:
        data[j] = 1
    for j in cd[i]:
        data[j] = -1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = []
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0):
                    data[frfr] = 1
                    new.append(frfr)
                    count += 1
                elif(data[frfr] == -1):
                    new.append(frfr)
        if(len(new)==0):
            break
        else:
            new_friends.append(new)
    ans.append(count)

print(*ans)

Fixed submission:
n,m,k = map(int,input().split())
ab = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)
cd = [set([]) for i in range(n)]
for i in range(k):
    c,d = map(int,input().split())
    cd[c-1].add(d-1)
    cd[d-1].add(c-1)
    
ans = [0 for i in range(n)]
data = [0 for i in range(n)] #見たら1
for i in range(n): #自分がi
    if(data[i] != 0): #もう見てたら必要なし
        continue
    data[i] = 1 #iの人を見る
    data2 = ab[i] + [i]
    data2 = set(data2)
    for j in ab[i]:
        data[j] = 1
    new_friends = [ab[i]]
    for fris in new_friends:
        new = [] #次の深さのリスト
        for fri in fris: #この層の友人を１人選ぶ
            for frfr in ab[fri]: #その友人の友人
                if(data[frfr] == 0): #見てなかったら加える
                    data[frfr] = 1 
                    new.append(frfr) #次の深さのリストに足す
                    data2.add(frfr) #グラフに足す
        if(len(new)==0):
            break
        else:
            new_friends.append(new)

    sam = len(data2)
    for j in data2:
        count = sam
        ans[j] = count - len(ab[j]) - len(cd[j] & data2) - 1 #自分と友達を除く


print(*ans)