Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = {}
    ANS = {}
    for i in range(1, n + 1):
        if C.get(i):
            continue

        C[i] = True
        Cin = {}
        Cin[i] = True
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()):
                if not Cin.get(f):
                    Q.appendleft(f)
                    C[f] = True
                    Cin[f] = True

        for k in Cin.keys():
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin.keys() & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = set()
    ANS = {}
    for i in range(1, n + 1):
        if i in C:
            continue

        C.add(i)
        Cin = set()
        Cin.add(i)
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()) - Cin:
                Q.appendleft(f)
                C.add(f)
                Cin.add(f)

        for k in Cin:
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df[a].add(b)
        Df[b].add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db[c].add(d)
        Db[d].add(c)

    Q = []
    C = {}
    ANS = {}
    for i in range(1, n + 1):
        if C.get(i):
            continue

        C[i] = True
        Cin = {}
        Cin[i] = True
        Q.append(i)
        while len(Q) != 0:
            for f in Df[Q.pop(0)]:
                if not Cin.get(f):
                    Q.append(f)
                    C[f] = True
                    Cin[f] = True

        for k in Cin.keys():
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin.keys() & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = set()
    ANS = {}
    for i in range(1, n + 1):
        if i in C:
            continue

        C.add(i)
        Cin = set()
        Cin.add(i)
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()) - Cin:
                Q.appendleft(f)
                C.add(f)
                Cin.add(f)

        for k in Cin:
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df[a].add(b)
        Df[b].add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db[c].add(d)
        Db[d].add(c)

    Q = []
    ANS = {}
    C = [False] * (n + 1)
    for i in range(1, n + 1):
        if C[i]:
            continue

        C[i] = True
        Cin = [False] * (n + 1)
        Cin[i] = True
        FF = set()
        FF.add(i)
        Q.append(i)
        while len(Q) != 0:
            for f in Df[Q.pop(0)]:
                if not Cin[f]:
                    Q.append(f)
                    FF.add(f)
                    C[f] = True
                    Cin[f] = True

        for ni in range(1, n + 1):
            if Cin[ni]:
                ANS[ni] = (Cin.count(True) - len(Df[ni]) - len(FF & Db[ni] - Df[ni]) - 1)

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = set()
    ANS = {}
    for i in range(1, n + 1):
        if i in C:
            continue

        C.add(i)
        Cin = set()
        Cin.add(i)
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()) - Cin:
                Q.appendleft(f)
                C.add(f)
                Cin.add(f)

        for k in Cin:
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df[a].add(b)
        Df[b].add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db[c].add(d)
        Db[d].add(c)

    Q = []
    ANS = []
    for i in range(1, n + 1):
        cnt = 0
        FF = set()
        C = [False]*(n + 1)
        C[i] = True
        Q.append(i)
        while len(Q) != 0:
            for f in Df[Q.pop(0)]:
                if not C[f]:
                    Q.append(f)
                    FF.add(f)
                    C[f] = True
                    cnt += 1

        ANS.append(cnt - len(Df[i]) - len(FF & Db[i] - Df[i]))

    print(*ANS)

if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = set()
    ANS = {}
    for i in range(1, n + 1):
        if i in C:
            continue

        C.add(i)
        Cin = set()
        Cin.add(i)
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()) - Cin:
                Q.appendleft(f)
                C.add(f)
                Cin.add(f)

        for k in Cin:
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m, k = [int(e) for e in input().split()]
    AB = [[int(e) for e in input().split()] for i in range(m)]
    CD = [[int(e) for e in input().split()] for i in range(k)]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for ab in AB:
        Df[ab[0]].add(ab[1])
        Df[ab[1]].add(ab[0])

    for cd in CD:
        Db[cd[0]].add(cd[1])
        Db[cd[1]].add(cd[0])

    Q = []
    ANS = []
    for i in range(1, n + 1):
        FF = set()
        C = [False]*(n + 1)
        C[i] = True
        Q.append(i)
        while len(Q) != 0:
            for f in Df[Q.pop(0)]:
                if not C[f]:
                    Q.append(f)
                    FF.add(f)
                    C[f] = True

        ANS.append(C.count(True) - len(Df[i]) - len(FF & Db[i] - Df[i]) - 1)

    print(*ANS)

if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque

def main():
    n, m, k = [int(e) for e in input().split()]

    Df, Db = {}, {}
    for i in range(1, n + 1):
        Df[i] = set()
        Db[i] = set()

    for i in range(m):
        a, b = [int(e) for e in input().split()]
        Df.get(a).add(b)
        Df.get(b).add(a)

    for i in range(k):
        c, d = [int(e) for e in input().split()]
        Db.get(c).add(d)
        Db.get(d).add(c)

    Q = deque()
    C = set()
    ANS = {}
    for i in range(1, n + 1):
        if i in C:
            continue

        C.add(i)
        Cin = set()
        Cin.add(i)
        Q.appendleft(i)
        while len(Q) != 0:
            for f in Df.get(Q.pop()) - Cin:
                Q.appendleft(f)
                C.add(f)
                Cin.add(f)

        for k in Cin:
            ANS[k] = len(Cin) - len(Df[k]) - len(Cin & Db[k] - Df[k]) - 1

    print(*[ANS[i] for i in range(1, n + 1)])

if __name__ == "__main__":
    main()