Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    S = input()
    cnt = 0
    for i in range(1000):
        ptn = str(i).zfill(3)
        j = 0
        flg = 0
        while j < N:
            if S[j] == ptn[flg]:
                flg += 1
                if flg == 3:
                    cnt += 1
                    break
            j += 1
    print(cnt)


if __name__ == '__main__':
    main()

Fixed submission:
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    S = input()
    cnt = 0
    for i in range(1000):
        ptn = str(i).zfill(3)
        j = 0
        flg = 0
        while j < N:
            if S[j] == ptn[flg]:
                flg += 1
                if flg == 3:
                    cnt += 1
                    break
            j += 1
    print(cnt)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        a = L[i]
        b = L[j]
        l = bisect.bisect_right(L, abs(a-b))
        r = bisect.bisect_left(L, a+b)
        ans += r-l
        if a in L[l:r]:
            ans -= 1
        if b in L[l:r]:
            ans -= 1
        
print(ans//3)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        a = L[i]
        b = L[j]
        l = bisect.bisect_right(L, abs(a-b))
        r = bisect.bisect_left(L, a+b)
        ans += r-l
        if L[l] <= a <= L[r-1]:
            ans -= 1
        if L[l] <= b <= L[r-1]:
            ans -= 1
        
print(ans//3)
Buggy python submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

g = math.gcd(A, B)

print(len(set(prime_decomposition(g)))+1)

Fixed submission:
from fractions import gcd

A, B = map(int, input().split())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

g = gcd(A, B)

print(len(set(prime_decomposition(g)))+1)
Buggy python submission (verdict: Runtime Error):
import bisect, collections

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, M = mi()
    A = list(mi())
    A.sort()
    d = collections.deque(A)
    for i in range(M):
        t = d.pop()
        t = t>>1
        bisect.insort_left(d, t)
    print(sum(d))


if __name__ == '__main__':
    main()


Fixed submission:
import heapq

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, M = mi()
    A = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(A)
    for i in range(M):
        t = heapq.heappop(A)
        heapq.heappush(A, -(-t//2))
    print(-sum(A))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, M = mi()
    A = list(mi())
    A.sort()
    for i in range(M):
        t = A.pop()
        t = t>>1
        bisect.insort_left(A, t)
    print(sum(A))


if __name__ == '__main__':
    main()


Fixed submission:
import heapq

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, M = mi()
    A = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(A)
    for i in range(M):
        t = heapq.heappop(A)
        heapq.heappush(A, -(-t//2))
    print(-sum(A))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, math
from functools import lru_cache
from collections import deque

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, Q = mi()
    a, b = i2(N-1)
    p, x = i2(Q)

    d = [[] for i in range(N)]
    for i in range(N-1):
        d[a[i]-1].append(b[i]-1)
        d[b[i]-1].append(a[i]-1)

    child = [[] for i in range(N)]
    parent = [None]*N

    q = deque([0])
    while q:
        now = q.pop()
        for v in d[now]:
            if parent[now] == v:
                continue
            parent[v] = now
            q.appendleft(v)

    c = [0]*N
    for i in range(Q):
        c[p[i]-1] += x[i]

    @lru_cache(maxsize=None)
    def dfs(i):
        if parent[i] == None:
            return c[i]
        
        return c[i]+dfs(parent[i])

    print(*[dfs(i) for i in range(N)])

if __name__ == '__main__':
    main()


Fixed submission:
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, Q = mi()
    a, b = i2(N-1)
    p, x = i2(Q)

    d = [[] for i in range(N)]
    for i in range(N-1):
        d[a[i]-1].append(b[i]-1)
        d[b[i]-1].append(a[i]-1)

    child = [[] for i in range(N)]
    parent = [None]*N

    q = deque([0])
    while q:
        now = q.pop()
        for v in d[now]:
            if parent[now] == v:
                continue
            parent[v] = now
            q.appendleft(v)

    c = [0]*N
    for i in range(Q):
        c[p[i]-1] += x[i]

    @lru_cache(maxsize=None)
    def dfs(i):
        if parent[i] == None:
            return c[i]
        
        return c[i]+dfs(parent[i])

    print(*[dfs(i) for i in range(N)])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, math, re
from itertools import accumulate
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    x, y = i2(N)
    d = {}

    for i in range(N):
        for j in range(N):
            if i == j:
                continue

            pair = (x[i]-x[j], y[i]-y[j])
            if not pair in d:
                d[pair] = 0
            
            d[pair] += 1

    print(N-max(d.values()))


if __name__ == "__main__":
    main()

Fixed submission:
import sys, math, re
from itertools import accumulate
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    if N == 1:
        print(1)
        return
        
    x, y = i2(N)
    d = {}

    for i in range(N):
        for j in range(N):
            if i == j:
                continue

            pair = (x[i]-x[j], y[i]-y[j])
            if not pair in d:
                d[pair] = 0
            
            d[pair] += 1

    print(N-max(d.values()))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import ceil, log2, pow

def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    ans = 0
    for i in range(1, N+1):
        ans += pow(0.5, max(0, ceil(log2(K)-log2(i))))/N
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
from math import ceil, log, pow

def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    ans = 0
    for i in range(1, N+1):
        ans += pow(0.5, max(0, ceil(log(K, 2)-log(i, 2))))/N
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    N = ii()
    A = list(mi())
    d = defaultdict(int)
    ans = 1

    for a in A:
        for v in make_divisors(a):
            d[v] += 1

    for k, v in d.items():
        if v >= N-1:
            ans = max(ans, k)

    print(ans)



if __name__ == '__main__':
    main()


Fixed submission:
import sys
from fractions import gcd
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    A = list(mi())

    L = [0]*N
    R = [0]*N
    L[1] = A[0]
    R[N-2] = A[N-1]

    M = [0]*N

    for i in range(N-2):
        L[i+2] = gcd(L[i+1], A[i+1])
    for i in range(N-2, 0, -1):
        R[i-1] = gcd(R[i], A[i])

    for i in range(N):
        if L[i] == 0:
            M[i] = R[i]
        elif R[i] == 0:
            M[i] = L[i]
        else:
            M[i] = gcd(R[i], L[i])
    
    print(max(M))



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from itertools import permutations

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, Q = mi()
    S = input()
    lr = [map(int, input().split()) for _ in range(Q)]
    l, r = [list(i) for i in zip(*lr)]

    dp = [0]*(N+1)
    for i in range(N):
        if S[i-1:i+1] == 'AC':
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]

    for i in range(Q):
        ans = dp[r[i]]-dp[l[i]]
        if S[l[i-2]:l[i]] == 'AC':
            ans -= 1
        print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
from itertools import permutations

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N, Q = mi()
    S = input()
    lr = [map(int, input().split()) for _ in range(Q)]
    l, r = [list(i) for i in zip(*lr)]

    dp = [0]*(N+1)
    for i in range(N):
        if S[i-1:i+1] == 'AC':
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]

    for i in range(Q):
        ans = dp[r[i]]-dp[l[i]]
        print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, X = mi()
    t = [1<<i for i in range(55)]
    def f(L, x, t):
        if L == 0:
            return 0 if X <= 0 else 1

        if x == 1:
            return 0
        elif 2 <= x <= t[L+1]-2:
            return f(L-1, x-1, t)
        elif x == t[L+1]-1:
            return t[L]
        elif t[L+1] <= x <= t[L+2]-4:
            return t[L]+f(L-1, x-t[L+1]+1, t)
        else:
            t[L+1]-1

    print(f(N, X, t))

if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, X = mi()
    a, p = [1], [1]
    for i in range(N):
        a.append(a[i]*2+3)
        p.append(p[i]*2+1)

    def f(N, X):
        if N == 0:
            return 0 if X <= 0 else 1

        if X <= 1 + a[N-1]:
            return f(N-1, X-1)
        else:
            return p[N-1]+1+f(N-1, X-2-a[N-1])

    print(f(N, X))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, X = mi()
    t = [1<<i for i in range(55)]
    def f(L, x, t):
        if L == 0:
            return 1

        if x == 1:
            return 0
        elif 2 <= x <= t[L+1]-2:
            return f(L-1, x-1, t)
        elif x == t[L+1]-1:
            return t[L]
        elif t[L+1] <= x <= t[L+2]-4:
            return t[L]+f(L-1, x-t[L+1]+1, t)
        else:
            t[L+1]-1

    print(f(N, X, t))

if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, X = mi()
    a, p = [1], [1]
    for i in range(N):
        a.append(a[i]*2+3)
        p.append(p[i]*2+1)

    def f(N, X):
        if N == 0:
            return 0 if X <= 0 else 1

        if X <= 1 + a[N-1]:
            return f(N-1, X-1)
        else:
            return p[N-1]+1+f(N-1, X-2-a[N-1])

    print(f(N, X))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, M = mi()
    S, T = [list(input()), list(input())]
    l = M*N//math.gcd(M, N)

    s = ['']*l
    t = ['']*l

    s[::l//N] = S
    t[::l//M] = T

    for i in range(l):
        if not (s[i] == '' or t[i] == '' or s[i] == t[i]):
            print(-1)
            return

    print(l)




if __name__ == '__main__':
    main()


Fixed submission:
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, M = mi()
    S, T = [list(input()), list(input())]

    g = math.gcd(N, M)
    l = N*M//g

    for i in range(g):
        if not (S[N//g*i] == T[M//g*i]):
            print(-1)
            return

    print(l)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()
    g = 1
    for i in range(1, M//N+1):
        if M%i==0:
            g = i
    print(g)

if __name__ == '__main__':
    main()


Fixed submission:
import sys, math
from functools import lru_cache
from collections import deque
from bisect import bisect_left
sys.setrecursionlimit(10**9)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, M = mi()

    d = []
    i = 1
    while i*i <= M:
        if M%i == 0:
            d.append(i)
            d.append(M//i)
        i += 1

    d.sort()

    for v in d:
        if v <= M//N:
            ans = v
        else:
            break

    print(ans)

    



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import product

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, K = mi()
    x = list(mi())
    m = 10**100
    for i in range(N-K+1):
        l = x[i:i+K]
        tmp = min(abs(l[0]), abs(l[-1]))+(l[-1]-l[0])
        m = min(m, tmp)
    print(m)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import product

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N, K = mi()
    x = list(mi())
    m = 10**100
    for i in range(N-K+1):
        tmp = min(abs(x[i]), abs(x[i+K-1]))+(x[i+K-1]-x[i])
        m = min(m, tmp)
    print(m)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
5 3 11
1
---
30
===
3 3 4
2
---
22
===


Fixed submission:
A, B, C = list(map(int,input().split()))
K = int(input())

print(A+B+C-max(A, B, C)+max(A, B, C)*(2**K))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

for v in range(A, B+1):
    if v < A+K or B-K < v:
        print(v)

Fixed submission:
A, B, K = map(int, input().split())

if A+K-1 < B-K+1:
    l = list(range(A, A+K))+list(range(B-K+1, B+1))
else:
    l = list(range(A, B+1))

for v in l:
    print(v)

Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
l = list(range(A, B+1))
l = sorted(list(set(l[:K]+l[-K:])))

for v in l:
    print(v)

Fixed submission:
A, B, K = map(int, input().split())

if A+K-1 < B-K+1:
    l = list(range(A, A+K))+list(range(B-K+1, B+1))
else:
    l = list(range(A, B+1))

for v in l:
    print(v)
Buggy python submission (verdict: Runtime Error):
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S = input()
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
        return

    l = [0]*26
    for c in S:
        l[ord(c)-ord('a')] += 1

    if len(S) < 26:
        i = l.index(0)
        print(S+chr(i+ord('a')))
        return

    for i in range(len(S)):
        if S[i] > S[i+1]:
            break

    c = min(S[i+1:])
    print(S[:i-1]+c)

if __name__ == '__main__':
    main()


Fixed submission:
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    S = input()
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
        return

    l = [0]*26
    for c in S:
        l[ord(c)-ord('a')] += 1

    if len(S) < 26:
        i = l.index(0)
        print(S+chr(i+ord('a')))
        return

    for i in range(len(S)-1, 0, -1):
        if S[i-1] < S[i]:
            break

    c = min(S[j] for j in range(i, len(S)) if S[j] > S[i-1])
    print(S[:i-1]+c)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
class UnionFind:
    """素集合を木構造として管理する"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.cnt = n

    def root(self, x):
        """要素xの根を求める"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を統合する"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1

    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める"""
        return self.root(x) == self.root(y)

    def get_size(self, x):
        """要素xを含む集合の要素数を求める"""
        return -self.parent[self.root(x)]

    def get_cnt(self):
        """集合の個数を求める"""
        return self.cnt


n, m = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(m)]


uf = UnionFind(n)
for u, v in edges:
    u -= 1
    v -= 1
    uf.merge(u, v)

ans = 0
for i in range(n):
    ans = max(uf.get_size(u), ans)
print(ans)

Fixed submission:
class UnionFind:
    """素集合を木構造として管理する"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.cnt = n

    def root(self, x):
        """要素xの根を求める"""
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def merge(self, x, y):
        """要素xを含む集合と要素yを含む集合を統合する"""
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parent[x] > self.parent[y]:
            x, y = y, x
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        self.cnt -= 1

    def is_same(self, x, y):
        """要素x, yが同じ集合に属するかどうかを求める"""
        return self.root(x) == self.root(y)

    def get_size(self, x):
        """要素xを含む集合の要素数を求める"""
        return -self.parent[self.root(x)]

    def get_cnt(self):
        """集合の個数を求める"""
        return self.cnt


n, m = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(m)]


uf = UnionFind(n)
for u, v in edges:
    u -= 1
    v -= 1
    uf.merge(u, v)

ans = 0
for i in range(n):
    ans = max(uf.get_size(i), ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

ans = 0
max_ = 0
for i in range(n):
    ans += max(max_ - a[i], 0)
    max_ = max(max_, a[i])
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

ans = 0
max_ = 0
for i in range(n):
    ans += max(max_ - a[i], 0)
    max_ = max(max_, a[i])
print(ans)