Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        #reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    sys.setrecursionlimit(100000)
    n, m, *ab, = map(int, open(0).read().split())

    p = [-1] * (n + 1)

    def f(x):
        if p[x] < 0:
            return x
        else:
            return f(p[x])

    def g(x, t):
        if p[x] < 0:
            return
        nx = p[x]
        p[x] = t
        g(nx, t)
        

    ans = -1
    order = set()
    for i, j in zip(ab[::2], ab[1::2]):
        if i > j:
            i, j = j, i
        if (i, j) in order:
            continue

        pi, pj = f(i), f(j)
        if pi == pj:
            continue
        p[pi] += p[pj]
        ans = min(ans, p[pi])
        p[j] = pi
        p[pj] = pi
        g(j, pi)
        order.add((i, j))
    print(-ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    sys.setrecursionlimit(100000)
    n, m, *ab, = map(int, open(0).read().split())

    p = [-1] * (n + 1)

    def f(x):
        if p[x] < 0:
            return x
        else:
            return f(p[x])

    ans = -1
    order = set()
    for i, j in zip(ab[::2], ab[1::2]):
        if i > j:
            i, j = j, i
        if (i, j) in order:
            continue

        pi, pj = f(i), f(j)
        if pi == pj:
            continue
        p[pi] += p[pj]
        ans = min(ans, p[pi])
        p[j] = pi
        p[pj] = pi
        order.add((i, j))
    print(-ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    sys.setrecursionlimit(100000)
    n, m, *ab, = map(int, open(0).read().split())

    p = [-1] * (n + 1)

    def f(x):
        if p[x] < 0:
            return x
        else:
            return f(p[x])

    ans = -1
    for i, j in zip(ab[::2], ab[1::2]):
        if i > j:
            i, j = j, i

        pi, pj = f(i), f(j)
        if pi == pj:
            continue
        p[pi] += p[pj]
        ans = min(ans, p[pi])
        p[j] = pi
        p[pj] = pi

    print(-ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n, m, *ab, = map(int, open(0).read().split())

    p = [-1] * (n + 1)

    def f(x):
        if p[x] < 0:
            return x
        else:
            return f(p[x])

    ans = -1
    for i, j in zip(ab[::2], ab[1::2]):
        if i > j:
            i, j = j, i

        pi, pj = f(i), f(j)
        if pi == pj:
            continue
        p[pi] += p[pj]
        ans = min(ans, p[pi])
        p[j] = pi
        p[pj] = pi

    print(-ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    n, m, *ab, = map(int, open(0).read().split())
    f = [set() for _ in range(n)]
    for i, j in zip(ab[::2], ab[1::2]):
        f[i].add(j)
        f[j].add(i)

    group = []
    i = 1
    g = {i}
    nx = {i}
    checked = set()
    m = 0
    ans = 0
    while i <= n:
        if i in checked:
            i += 1
            continue

        tmp = set()
        for j in list(nx):
            tmp |= f[j]
        tmp -= nx

        if len(tmp) == 0:
            checked |= g
            group.append(g)
            l = len(g)
            m += l
            r = n - m
            ans = max(ans, l)
            if l >= r:
                break
            i += 1
            g = {i}
        else:
            g |= tmp
            nx = tmp

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    from collections import defaultdict
    n, m, *ab, = map(int, open(0).read().split())
    f = defaultdict(lambda: set())
    for i, j in zip(ab[::2], ab[1::2]):
        f[i].add(j)
        f[j].add(i)

    group = []
    i = 1
    g = {i}
    nx = {i}
    checked = set()
    while i <= n:
        if i in checked:
            i += 1
            continue
        checked |= g
        tmp = set()
        for j in list(nx):
            tmp |= f[j]
        tmp -= checked

        if len(tmp) == 0:
            group.append(g)
            i += 1
            g = {i}
            continue
        else:
            g |= tmp
            nx = tmp

    ans = max(list(map(len, group)))
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n, m, *ab, = map(int, open(0).read().split())
    p = [-1] * (n + 1)

    def find(x):
        while p[x] > 0:
            x = p[x]
        return x

    def union(i, j):
        pi, pj = find(i), find(j)
        if pi == pj:
            return
        if p[pi] < p[pj]:
            pi, pj = pj, pi
            i, j = j, i
        p[pi] += p[pj]
        p[pj] = pi
        reconnect(j, pi)

    def reconnect(i, j):
        while p[i] > 0:
            k = p[i]
            p[i] = j
            i = k

    for i, j in zip(ab[::2], ab[1::2]):
        union(i, j)

    print(-min(p))


if __name__ == '__main__':
    main()